" Tab options set tabstop=8 " When reading a file, show a tab ('\t') as 8 spaces set softtabstop=4 " When inserting a tab (eg, pressing 'tab'), insert 4 spaces set shiftwidth=4 " Number of spaces to indent when using '>>' set expandtab " Never insert an actual tab character -- always use spaces set autoindent " Copy indent from current line to next when enter is pressed set history=1000 " Keep lots and lots of history " See also: :help retab " Formatting options set formatoptions=cqn " c: auto-wrap comments to textwidth " q: Allow formatting comments with 'gq' " n: Recognized numbered lists (eg: '1. ...\n 2. ... \n') " See also: :help fo-table " Searching options set ignorecase " Ignore case when searching set smartcase " See :help smartcase (trust me, it's useful) set incsearch " Incremental search set hlsearch " Hilight searches " Make sure that the leader is '\' let mapleader="\\" " Turn off highlighting when \ is pressed map \ :noh " FuzzyFinder FTW http://www.vim.org/scripts/script.php?script_id=1984 map f :FuzzyFinderFile map F :FuzzyFinderTaggedFile map t :FuzzyFinderTag map b :FuzzyFinderBuffer " File type things syntax enable " Turn on syntax hilighting filetype on " Enable filetype detection filetype indent on " Enable filetype-specific indenting filetype plugin on " Enable filetype-specific plugins " Use to execute the current file (equivilent to ./$FILE) map :!%:p " XML, HTML and Javascript have very bad indent settings... Don't use them. " autocmd BufEnter *.js setlocal indentexpr= " Stop auto-indenting " autocmd BufEnter *.js setlocal nocin " autocmd BufEnter *.js setlocal smartindent " autocmd BufEnter *.js setlocal autoindent " When switching to a file, enter its directory autocmd BufEnter * :lcd %:p:h " Miscalanious stuff... set backspace=indent,eol,start " Better backspacing set ruler " Show a ruler along the bottom of the screen set lz " Don't re-draw while running macros set hid " Can hide buffers without closing them set shortmess=atI " shortens messages to avoid 'press a key' prompt set scrolloff=3 " Always keep three lines above or below the cursor set nocompatible " Keep vim from trying to be 100% vi compatible set title " Set the window title set showcmd " Show (partial) command in status line. set wildmenu " Pretty command-line option matching set wildmode=list:longest " Shell-style matching set wildignore=*.bak,*.o,*.e,*~,*.pyc " Suffixes that get lower priority when doing tab completion for filenames. " These are files we are not likely to want to edit or read. set suffixes=.bak,~,.swp,.o,.info,.aux,.log,.dvi,.bbl,.blg,.brf,.cb,.ind,.idx,.ilg,.inx,.out,.toc,.class,.pyc set tags=tags;/ set statusline=%f%m%r%h%w\ [%Y]\ [0x\%02.2B]%<\ %F%=%4v,%4l\ %3p%%\ of\ %L set laststatus=2 " Always show status line set modelines=5 " Allow modelines within 5 lines of top/bottom " Folding opttions set foldmethod=marker " When editing CPython source, run their provided vimrc (setting certain useful " things like their coding standards) let py_source = '\(Py3k-svn\|Python-trunk\)' let path = expand('%:p:h') if path =~ py_source let path = substitute(path, '\(.*/' . py_source . '\).*', '\1', '') execute('source ' . path . '/Misc/Vim/vimrc') endif " Make p in Visual mode replace the selected text with the "" register. vnoremap p :let current_reg = @"gvdi=current_reg " Move to the first non-whitespace character when 0 is pressed and the first " character on the line when ^ is pressed (instead of vice-versa) noremap 0 ^ noremap ^ 0 " Use j and k to move down and up _logical_ lines instead of line-break lines nmap j gj nmap k gk " Use to insert a blank line below the current line map ok " NetRW (the file browser) stuff... Safe to ignore :) let g:netrw_sort_sequence='[\/]$,*,\.bak$,\.o$,\.h$,\.info$,\.swp$,\.obj$,\.pyc$' let g:netrw_keepdir=0 let g:netrw_browse_split=0 " NERD tree " Toggle map d :execute 'NERDTreeToggle ' . getcwd() " I often hit 'e' instead of 'o', so change the 'open explorer' from 'e' to " 'E' (it's annoying to have an explorer open when I don't want one) let g:NERDTreeMapOpenExpl = 'E' " Some windowing convinience methods map h map j map k map l map _ map _ map + + map - - " Who needs arrow keys anyway? map :bn map :bp map :cp map :cn "set t_kb= " Fix backspace problems on some machines "fixdel " But this creates backspace problems on others... :( " CSC369 stuff let curpath = expand('%:p:h') if curpath =~ 'CSC369/' " map gc (Goto Callers) to find all the places where is used map gc :grep -R ~/School/CSC369/src/kern/ " Setup the path so find will work set path=~/School/CSC369/src/** endif " Exchange the jumping characteristics of ' and ` nnoremap ' ` nnoremap ` ' " Faster scrolling nnoremap nnoremap " Uncomment this line to use to open a terminal " map  :!gnome-terminal & colorscheme tolerable hi Folded ctermbg=none ctermfg=White cterm=none hi Pmenu ctermbg=none ctermfg=White cterm=none hi PmenuSel ctermbg=darkgrey ctermfg=White cterm=none hi PmenuThumb ctermbg=white ctermfg=white hi PmenuSbar ctermbg=black ctermfg=black " Match braces just by white-bolding them, not making them cyan hi MatchParen ctermbg=none ctermfg=white term=bold cterm=bold set showmatch " Show matching brackets. set matchtime=1 if has('gui_running') set guioptions-=T " no toolbar end if has('cmdlog') set cmdlogdir=~/.vimlogs/ end " Helpful for when other people use my Vim fun! NoCrazyBindings() unmap unmap unmap unmap endfun " When editing a file, always jump to the last known cursor position. " Don't do it when the position is invalid or when inside an event handler " (happens when dropping a file on gvim). " Also don't do it when the mark is in the first line, that is the default " position when opening a file. autocmd BufReadPost * \ if line("'\"") > 1 && line("'\"") <= line("$") | \ exe "normal! g`\"" | \ endif " Convenient command to see the difference between the current buffer and the " file it was loaded from, thus the changes you made. " Only define it when not defined already. if !exists(":DiffOrig") command DiffOrig vert new | set bt=nofile | r # | 0d_ | diffthis \ | wincmd p | diffthis endif " Make 'grep' ignore '.svn' directories and recurse set grepprg=grep\ -R\ --exclude='*.svn*'\ -n\ $* " Fix a diff, making it easier to review. " Add a blank line before each '@@ ... hunk line info ...@@' and each 'diff', " making it easier to jump around using { and } fun! ReviewDiff() let oldreg_val = getreg('d') let oldreg_type = getregtype('d') call setreg('d', '', 'V') g/^diff/put! d g/^@@/put! d call setreg('d', oldreg_val, oldreg_type) endfun " Enable perdy 256 color mode " set t_Co=256