" OPTIONS set nocompatible " use vim defaults instead of 100% vi compatibility set autoindent " autoindent line based on previous line set backspace=indent,eol,start " more powerful backspacing set diffopt=filler,iwhite,vertical " keep files synced and ignore whitespace set formatprg=par\ -w " gq formats with par (line width 79) set gdefault " toggle behavior of /g flag in substitutions set history=50 " keep 50 lines of command line history set hlsearch " highlight search results set ignorecase " case-insensitive search set laststatus=2 " always show status line set linebreak " break long lines at words set listchars=eol:$,nbsp:.,trail:- " characters to show when list is set set nojoinspaces " don't double space between sentences when using J set nomodeline " security risk set number " show line numbers set pastetoggle=p " makes pasting text not mess stuff up set scrolloff=4 " show this many lines before/after cursor set shiftround " < and > round to nearest multiple of shiftwidth set smartcase " search is case-sensitive if it contains caps set smartindent " smart indent for bracket matching, etc. set spelllang=en_us " use US English for spelling set statusline=(%n)\ %<%F\ %h%m%r\ %=%-19.(%l/%L,%c%V%)\ %P " like default with ruler but with buffer number, full path, and line count set suffixes+=.class " file name completion gives these less love set tabpagemax=30 " max tabs to open with -p or :tab all - too many will crash vim set virtualedit=block " easier to select stuff in visual block mode set wildmenu " be more helpful about command suggestions set wildmode=list:longest " shell-like command-line completion " custom tab pages line with tab numbers - modified version of script by JonSkanes " http://vim.wikia.com/index.php?title=Show_tab_number_in_your_tab_line&oldid=29439 set tabline=%!MyTabLine() function MyTabLine() let s = '' " complete tabline goes here " loop through each tab page for t in range(tabpagenr('$')) " select the highlighting for the buffer names if t + 1 == tabpagenr() let s .= '%#TabLineSel#' else let s .= '%#TabLine#' endif let s .= ' [' " set the tab page number (for mouse clicks) let s .= '%' . (t + 1) . 'T' " set page number string let s .= t + 1 . ']' " get buffer names and statuses let n = '' "temp string for buffer names while we loop and check buftype let m = 0 " &modified counter let bc = len(tabpagebuflist(t + 1)) "counter to avoid last ',' " loop through each buffer in a tab for b in tabpagebuflist(t + 1) " buffer types: quickfix gets a [Q], help gets [H]{base fname} if getbufvar( b, "&buftype" ) == 'help' let n .= '[H]' . fnamemodify( bufname(b), ':t:s/.txt$//' ) elseif getbufvar( b, "&buftype" ) == 'quickfix' let n .= '[Q]' elseif bufname(b) == '' let n .= '[No Name]' else "let n .= pathshorten(bufname(b)) "let n .= bufname(b) let n .= fnamemodify( bufname(b), ':t' ) endif " check and ++ tab's &modified count if getbufvar( b, "&modified" ) let m += 1 endif " no final ' ' added...formatting looks better done later if bc > 1 let n .= ',' endif let bc -= 1 endfor " add modified label [+] where n pages in tab are modified if m > 0 "let s .= '[' . m . '+]' let s.= '[+]' endif let s .= ' ' " add buffer names let s .= n " switch to no underlining and add final space to buffer list "let s .= '%#TabLineSel#' . ' ' let s .= ' ' endfor " after the last tab fill with TabLineFill and reset tab page nr let s .= '%#TabLineFill#%T' return s endfunction " INDENTING syntax on " this has to go before the syntax autocmds or else they won't work set noexpandtab tabstop=5 softtabstop=0 shiftwidth=5 highlight BadIndent ctermbg=1 autocmd Syntax {bash,css,html,java,javascript,python,php,sh,vim,xml} call matchadd('BadIndent', '^\t*\zs \+') " FOLDING set foldcolumn=2 foldminlines=5 foldlevelstart=1 " see which syntaxes may enable folding " !grep -l fold $VIMRUNTIME/syntax/*.vim let javaScript_fold=1 let php_folding=1 let sh_fold_enabled=1 let vimsyn_folding='af' let xml_syntax_folding=1 autocmd Syntax {java,javascript,php,sh,vim,xml} setlocal foldmethod=syntax autocmd Syntax python setlocal foldmethod=indent " FILE TYPES " this has to go after the custom indenting/folding stuff I guess autocmd FileType html set filetype=php syntax=php " COLORS " foldcolumn and folded lines - cyan on black hi FoldColumn ctermbg=0 ctermfg=6 hi Folded ctermbg=0 ctermfg=6 " diff colors: green, yellow, red hi DiffAdd ctermbg=2 hi DiffChange ctermbg=3 hi DiffDelete ctermbg=1 hi DiffText ctermbg=5 " word completion list - more legible hi PmenuSel ctermbg=7 ctermfg=5 " ABBREVIATIONS cab vh vert help cab W w " MAPPINGS " Y should act from the cursor to the end of the line, like D map Y y$ " put a new empty line at the Next/Previous line in normal mode " http://vim.wikia.com/wiki/Quickly_adding_and_deleting_empty_lines nnoremap :let save_paste = &paste:set pastem`o``:let &paste = save_paste nnoremap :let save_paste = &paste:set pastem`O``:let &paste = save_paste " search vim docs for word under cursor ("get a clue") " http://vim.wikia.com/wiki/Word_under_cursor_for_command nnoremap gc "xyw:exe "vert help ".@x."" " get rid of ZZ - it's the same as :x and could be typed instead of zz nmap ZZ " remove parentheses around something nnoremap b "xdibd%"xP nnoremap t :set list! " copy to X clipboard - copies lines selected in visual mode " http://vim.wikia.com/wiki/GNU/Linux_clipboard_copy/paste_with_xclip vmap :!xclip -f -sel clip " keep selection after indenting in visual mode vmap > >gv vmap < ,!unexpand -t --first-only command -nargs=1 -range=% Untab ,!expand -t -i " TERMINAL OPTIONS " change title for screen and byobu (screen-bce) " http://vim.wikia.com/wiki/Automatically_set_screen_title if &term == "screen" || &term == "screen-bce" set t_ts=k set t_fs=\ endif if &term == "screen" || &term == "screen-bce" || &term == "xterm" set titlestring=%t set title endif