" Curby's vimrc " To find a section, search for the equals sign followed by a section " name. like `/=' then a section name like Display " At the console, `grep '^" =' ~/.vimrc` to find section names """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " =General "..................................................................... " Out with the old set nocompatible " When tab-completing filenames, give these extensions lower priority set suffixes=.bak,~,.swp,.o,.obj,.info,.aux,.log,.dvi,.bbl,.blg,.brf,.cb,.ind,.idx,.ilg,.inx,.out,.toc " History and undo levels set history=100 set undolevels=500 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " =UI " These rules determine WHAT is displayed for window UI elements " Rules governing HOW elements are displayed are under Display " Rules governing the actual text are under Indentation "..................................................................... " Don't change terminal window title set notitle " Always show a status line (so we don't need to set ruler) set laststatus=2 " Format the status line " Truncate here Filetype Linebreaks: (D)os (M)ac (U)nix " | Filename for unmodified file | | Split justification " | | and for modified file | | | Position " | | | | | | | " [][------------][--------------------] [] [-------] [][-----------------] set statusline=%<%{StatusFN(0)}%1*%{StatusFN(1)}%m%0*\ (%Y/%{&ff[0]})%=%-14.(%l,%c%V%)\ %P function StatusFN(changed) if &mod == a:changed | return expand('%') | else | return '' | endif endfunction " Turn off bells and whistles set novisualbell noerrorbells " Show indicator for insert, replace, and visual modes (default) set showmode " Show partially-typed commands set showcmd " Show number of lines changed by : commands set report=0 " Remember position in line for page commands (C-B, C-F, C-D, C-U) set nostartofline " It's wild! set wildmenu wildmode=longest:full,full " Confirm instead of fail for actions that would destroy changes set confirm " Allocate two lines for command area set cmdheight=2 " Keep three lines of context around cursor visible set scrolloff=3 " Show line numbers set number """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " =Search, find, replace " These rules affect search logic/behavior " Rules for highlighting search results are in Display "..................................................................... " Case insensitive unless search string contains caps set ignorecase smartcase " Use incremental search (find as you type) set incsearch " Assume global searches for :s " Not used becaues it toggles with the 'g' flag to :s "set gdefault """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " =Display, Syntax Highlighting, Colors " These rules only change HOW characters are displayed " Rules governing WHAT is displayed are under UI "..................................................................... " Highlight search matches set hlsearch " Highlight matching parens for this many tenths of seconds set showmatch matchtime=3 " Turn on syntax highlighting syntax on " Carpe noctem set background=dark " Define a color scheme to use hi clear " Reset colors hi Comment ctermfg=LightCyan hi Constant ctermfg=LightMagenta hi Special ctermfg=Yellow hi Identifier ctermfg=DarkCyan hi Statement ctermfg=White hi PreProc ctermfg=LightBlue hi Type ctermfg=Yellow hi Ignore ctermfg=Black hi Error ctermfg=White ctermbg=Red hi Todo ctermfg=LightRed ctermbg=Yellow " For line numbers hi LineNr ctermfg=DarkRed " For modified files on the status line hi User1 term=inverse,bold cterm=inverse,bold ctermbg=LightRed " For code folding hi Folded ctermfg=Gray " Don't display EOL chars explicitly, show tabs and trailing spaces execute 'set listchars=tab:'.nr2char(187).nr2char(183).',trail:'.nr2char(183) set list """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " =Indentation, text flow "..................................................................... " Indent each line based on the last line intelligently set autoindent smartindent " Tabs expand to two spaces set expandtab tabstop=2 " Shift to tab stops set shiftwidth=2 shiftround " That's a wrap! set nowrap " Code Folding (Find a good expr to use with expr folding) set foldmethod=marker set foldcolumn=2 set foldtext=Myfoldtext() " This function moves the indent to the front so the left edge of folded " code looks cleaner " (v.folddashes doesn't work with literal spaces for indenting) function Myfoldtext() let firstline=getline(v:foldstart) let numlines=v:foldend-v:foldstart+1 if numlines < 10 | let numlines=numlines.' ' | endif let indent=substitute(firstline, '[^ \t].*', '', '') let sub=substitute(firstline, '/\*\|\*/\|{{{\d\=', '', 'g') let sub=substitute(sub, '^[ \t]*', '', '') return indent.numlines.": ".sub endfunction " Umm... this looks like mixed tab and space crap "set softtabstop=2 " For C indentation... prolly don't need "set cinoptions=>2 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " =Keys, bindings, maps "..................................................................... " Backspace can kill pretty much everything set backspace=indent,eol,start " Arrow keys can cross line boundaries at any time set whichwrap=b,s,<,>,[,] " Space pages down, backspace pages up (annoying) "noremap "noremap " Allow tab and shift-tab to affect indentation of visual mode blocks vmap > vmap " Use 'g' to go to the top of the file. map g 1G """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " =Filetypes "..................................................................... filetype on if &filetype == "" set filetype=text endif " Do some things only for C-like stuff function! SetupC() " Expansions - Turn this into this with cursor at x " {{{ {{{ " x " }}} " " /** /** " * x " */ " " /* /* x*/ inoremap {{{ {{{}}}A inoremap /** /** * */A inoremap /* /* */ setlocal cindent setlocal cinoptions=c0,C1 endfunction function! SetupCSS() call SetupC() " We don't want selectors indented like C switch statements " XXX doesn't seem to work setlocal cinoptions+=l1,:1s,=1s endfunction function! SetupMakefile() " Make it painfully clear when tabs are used execute 'setlocal listchars=trail:'.nr2char(183) . ',tab:'.nr2char(187).nr2char(183) setlocal list " Use tab stops of 8 at the beginning of lines, and spaces inside setlocal noexpandtab tabstop=8 shiftwidth=8 smarttab endfunction " Ensure our autocmds are defined once without nuking others if !exists("custom_autocmds_loaded") let custom_autocmds_loaded = 1 " detect filetypes that vim doesn't (this is Vim v6.2) autocmd BufRead,BufNewFile *.phps setfiletype php " custom setups for certain file types autocmd Filetype make call SetupMakefile() autocmd Filetype c,cpp,java,php call SetupC() "autocmd Filetype css call SetupCSS() endif