" --------------------------------------------------------------------------- " General " --------------------------------------------------------------------------- set nocompatible " essential set history=1000 " lots of command line history set confirm " error files / jumping set fileformats=unix,dos,mac " support these files filetype plugin indent on " load filetype plugin set iskeyword+=_,$,@,%,#,- " none word dividers set viminfo='1000,f1,:100,@100,/20 set modeline " make sure modeline support is enabled set autoread " reload files (no local changes only) " --------------------------------------------------------------------------- " Colors / Theme " --------------------------------------------------------------------------- if &t_Co > 2 || has("gui_running") if has("terminfo") set t_Co=16 set t_AB=[%?%p1%{8}%<%t%p1%{40}%+%e%p1%{92}%+%;%dm set t_AF=[%?%p1%{8}%<%t%p1%{30}%+%e%p1%{82}%+%;%dm else set t_Co=16 set t_Sf=[3%dm set t_Sb=[4%dm endif syntax on set hlsearch " Highlight all search matches " Press Space to turn off highlighting and clear any message already displayed. :nnoremap :nohlsearch:echo colorscheme slate2 endif " --------------------------------------------------------------------------- " Highlight " --------------------------------------------------------------------------- highlight Comment ctermfg=DarkGrey guifg=#444444 highlight StatusLineNC ctermfg=Black ctermbg=DarkGrey cterm=bold highlight StatusLine ctermbg=Black ctermfg=LightGrey " ---------------------------------------------------------------------------- " Highlight Trailing Whitespace " ---------------------------------------------------------------------------- set list listchars=trail:.,tab:>. highlight SpecialKey ctermfg=DarkGray ctermbg=Black " ---------------------------------------------------------------------------- " Backups " ---------------------------------------------------------------------------- set nobackup " do not keep backups after close set nowritebackup " do not keep a backup while working set noswapfile " don't keep swp files either set backupdir=$HOME/.vim/backup " store backups under ~/.vim/backup set backupcopy=yes " keep attributes of original file set backupskip=/tmp/*,$TMPDIR/*,$TMP/*,$TEMP/* set directory=~/.vim/swap,~/tmp,. " keep swp files under ~/.vim/swap " ---------------------------------------------------------------------------- " UI " ---------------------------------------------------------------------------- set ruler " show the cursor position all the time set noshowcmd " don't display incomplete commands set nolazyredraw " turn off lazy redraw "set number " line numbers set wildmenu " turn on wild menu set wildmode=list:longest,full set ch=2 " command line height set backspace=2 " allow backspacing over everything in insert mode set whichwrap+=<,>,h,l,[,] " backspace and cursor keys wrap to set shortmess=filtIoOA " shorten messages set report=0 " tell us about changes set nostartofline " don't jump to the start of line when scrolling " ---------------------------------------------------------------------------- " Visual Cues " ---------------------------------------------------------------------------- set showmatch " brackets/braces that is set mat=5 " duration to show matching brace (1/10 sec) set incsearch " do incremental searching set laststatus=2 " always show the status line set ignorecase " ignore case when searching set smartcase " case-sensitive if search contains an uppercase character set visualbell " shut the heck up " ---------------------------------------------------------------------------- " Text Formatting " ---------------------------------------------------------------------------- set autoindent " automatic indent new lines set smartindent " be smart about it set nowrap " do not wrap lines set softtabstop=2 " yep, two set shiftwidth=2 " .. set tabstop=4 set expandtab " expand tabs to spaces set nosmarttab " screw tabs set formatoptions+=n " support for numbered/bullet lists set textwidth=80 " wrap at 80 chars by default set virtualedit=block " allow virtual edit in visual block .. " ---------------------------------------------------------------------------- " Tabs " ---------------------------------------------------------------------------- if version >= 700 set tabpagemax=50 " open 50 tabs max endif " ---------------------------------------------------------------------------- " Mappings " ---------------------------------------------------------------------------- " to pastetoggle, to turn-off autoindent when pasting from system clipboard nnoremap :set invpaste paste? set pastetoggle= set showmode "" /- to navigation between buffers if version >= 700 set switchbuf=usetab nnoremap :sbnext nnoremap :sbprevious endif "" quickfix mappings "map :cn "map :cp "map :copen "" emacs movement keybindings in insert mode "imap 0 "imap $ "map $ "map 0 " reflow paragraph with Q in normal and visual mode nnoremap Q gqap vnoremap Q gq "" sane movement with wrap turned on "nnoremap j gj "nnoremap k gk "vnoremap j gj "vnoremap k gk "nnoremap gj "nnoremap gk "vnoremap gj "vnoremap gk "inoremap gj "inoremap gk "" do not menu with left / right in command line "cnoremap "cnoremap " ---------------------------------------------------------------------------- " Auto Commands " ---------------------------------------------------------------------------- " jump to last position of buffer when opening au BufReadPost * if line("'\"") > 0 && line("'\"") <= line("$") | \ exe "normal g'\"" | endif " don't use cindent for javascript autocmd FileType javascript setlocal nocindent " ---------------------------------------------------------------------------- " LookupFile " ---------------------------------------------------------------------------- "let g:LookupFile_TagExpr = '".ftags"' "let g:LookupFile_MinPatLength = 2 "let g:LookupFile_ShowFiller = 0 " fix menu flashiness "let g:LookupFile_PreservePatternHistory = 1 " preserve sorted history? "let g:LookupFile_PreserveLastPattern = 0 " start with last pattern? " "nmap LookupFile "imap LookupFile " ---------------------------------------------------------------------------- " PATH on MacOS X " ---------------------------------------------------------------------------- if system('uname') =~ 'Darwin' let $PATH = $HOME . \ '/usr/local/bin:/usr/local/sbin:' . \ '/usr/pkg/bin:' . \ '/opt/local/bin:/opt/local/sbin:' . \ $PATH endif " --------------------------------------------------------------------------- " sh config " --------------------------------------------------------------------------- au Filetype sh,bash set ts=4 sts=4 sw=4 expandtab let g:is_bash = 1 " --------------------------------------------------------------------------- " Misc mappings " --------------------------------------------------------------------------- "map ,f :tabnew "map ,d :e %:h/ "map ,dt :tabnew %:h/ "" I use these commands in my TODO file "map ,a o:r!date +'\%A, \%B \%d, \%Y':r!date +'\%A, \%B \%d, \%Y' \| sed 's/./-/g'A "map ,o o[ ] "map ,O O[ ] "map ,x :s/^\[ \]/[x]/ "map ,X :s/^\[x\]/[ ]/ " --------------------------------------------------------------------------- " Strip all trailing whitespace in file " --------------------------------------------------------------------------- function! StripWhitespace () exec ':%s/ \+$//gc' endfunction map ,s :call StripWhitespace () " --------------------------------------------------------------------------- " File Types " --------------------------------------------------------------------------- au Filetype gitcommit set tw=68 spell "au Filetype html,xml,xsl,rhtml source $HOME/.vim/scripts/closetag.vim " -------------------------------------------------------------------------- " ManPageView " -------------------------------------------------------------------------- let g:manpageview_pgm= 'man -P "/usr/bin/less -is"' let $MANPAGER = '/usr/bin/less -is'