" display options { syntax on "syntax coloring is a first-cut debugging tool colorscheme cyberpunk "change to taste. try `desert' or `evening' set wrap "wrap long lines set scrolloff=3 "keep three lines visible above and below set ruler showcmd "give line, column, and command in the status line set laststatus=2 "always show the status line "make filename-completion more terminal-like set wildmode=longest:full set wildmenu "a menu for resolving ambiguous tab-completion "files we never want to edit set wildignore=*.pyc,*.sw[pno],.*.bak,.*.tmp set incsearch "search as you type set hlsearch "highlight the search set ignorecase "ignore case set smartcase " ...unless the search uses uppercase letters set number " } " movement options { "enable mouse in normal, visual, help, prompt modes "I skip insert/command modes because it prevents proper middle-click pasting "TODO: can we get paste to work even with mouse enabled? set mouse=nvrh " Moving up/down moves visually. " This makes files with very long lines much more manageable. nnoremap j gj nnoremap k gk " Moving left/right will wrap around to the previous/next line. set whichwrap=b,s,h,l,<,>,~,[,] " Backspace will delete whatever is behind your cursor. set backspace=indent,eol,start "Bind the 'old' up and down. Use these to skip past a very long line. noremap gj j noremap gk k " } " general usability { "turn off the annoying "ding!" set visualbell "allow setting extra option directly in files "example: "vim: syntax=vim" set modeline "don't clobber the buffer when pasting in visual mode vmap P p vnoremap p "_dP " } " windows-style mappings { "ctrl+S to save. "NOTE: put this in ~/.bashrc for it to work properly in terminal vim: " stty -ixon -ixoff map :update imap "ctrl+A to select all noremap ggVG imap "ctrl+C to copy map "+y "ctrl+Y to redo map imap imap "ctrl+Z to undo "map u "this clobbers UNIX ctrl+z to background vim imap u "ctrl+Q to save/quit map :update\|q imap " } " common typos { " Often I hold shift too long when issuing these commands. command! Q q command! Qall qall command! W w command! Wall wall command! WQ wq command! Wq wq nmap Q: :q " this one causes a pause whenever you use q, so I don't use it " nmap q: :q "never use Ex mode -- I never *mean* to press it nnoremap Q "never use F1 -- I'm reaching for escape noremap noremap! lnoremap " } " multiple files { " be smarter about multiple buffers / vim instances "quick buffer switching with TAB, even with edited files set hidden nmap :bn nmap :bp set autoread "auto-reload files, if there's no conflict set shortmess+=IA "no intro message, no swap-file message "replacement for CTRL-I, also known as noremap "window switching: ctrl+[hjkl] nnoremap j nnoremap k nnoremap h nnoremap l nnoremap q "tab switching: ctrl+left/right nnoremap Od :tabp nnoremap Oc :tabN " } "indentation options { set expandtab "use spaces, not tabs set softtabstop=4 shiftwidth=4 "4-space indents set shiftround "always use a multiple of 4 for indents set smarttab "backspace to remove space-indents set autoindent "auto-indent for code blocks "DONT USE: smartindent "it does stupid things with comments "smart indenting by filetype, better than smartindent filetype on filetype indent on filetype plugin on " } "extra filetypes { au BufNewFile,BufRead *.js.tmpl set filetype=javascript au BufNewFile,BufRead *.css.tmpl set filetype=css au BufNewFile,BufRead *.pxi set filetype=pyrex au BufNewFile,BufRead *.md set filetype=markdown " } " tkdiff-like bindings for vimdiff { if &diff "next match nnoremap m ]cz. "previous match nnoremap M [cz. "refresh the diff nnoremap R :w\|set nodiff\|set diff "quit, both panes nnoremap q :qall "show me the top of the "new" file autocmd VimEnter * normal lgg endif " } " My own extra stuff: if filereadable($HOME . "/.vimrc.extra") source $HOME/.vimrc.extra endif set runtimepath^=~/.vim/bundle/ctrlp.vim filetype plugin indent on syntax on