diff --git a/vimrc b/vimrc index 317bda1..5bf23ec 100644 --- a/vimrc +++ b/vimrc @@ -7,8 +7,39 @@ set showcmd " display incomplete commands set incsearch " do incremental searching map Q gq vnoremap p :let current_reg = @"gvs=current_reg -set autoindent " always set autoindenting on +" Only do this part when compiled with support for autocommands. +if has("autocmd") + + " Enable file type detection. + " Use the default filetype settings, so that mail gets 'tw' set to 72, + " 'cindent' is on in C files, etc. + " Also load indent files, to automatically do language-dependent indenting. + filetype plugin indent on + + " Put these in an autocmd group, so that we can delete them easily. + augroup vimrcEx + au! + + " For all text files set 'textwidth' to 78 characters. + autocmd FileType text setlocal textwidth=78 + + " 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). + autocmd BufReadPost * + \ if line("'\"") > 0 && line("'\"") <= line("$") | + \ exe "normal g`\"" | + \ endif + autocmd BufRead *.rdoc setlocal filetype=text + + augroup END + +else + + set autoindent " always set autoindenting on + +endif " has("autocmd") " Switch syntax highlighting on, when the terminal has colors " Also switch on highlighting the last used search pattern. if &t_Co > 2 || has("gui_running") @@ -21,6 +52,8 @@ if has("gui_running") set guioptions-=T endif +au BufNewFile,BufRead *.ltx set wm=4 + set backupdir=/tmp set path+=lib/** @@ -32,15 +65,6 @@ set sw=2 set et set kp=ri -map rt :!ctags --extra=+f -R * -set scrolloff=2 -set ruler -set laststatus=2 -set statusline=%t%(\ [%n%M]%)%(\ %H%R%W%)\ %(%c-%v,\ %l\ of\ %L,\ (%o)\ %P\ 0x%B\ (%b)%) -set lines=40 -set columns=80 -setlocal spell spelllang=en_us - fun GitGrep(...) let save = &grepprg set grepprg=git\ grep\ -n\ $* @@ -60,9 +84,33 @@ func GitGrepWord() endf nmap G :call GitGrepWord() +" Run Ruby unit tests with gT (for all) or gt (only test under +" cursor) in command mode +augroup RubyTests + au! + autocmd BufRead,BufNewFile *_test.rb,test_*.rb + \ :nmap rt V:!$HOME/.vim/bin/ruby_run_focused_unit_test + \ % =line("'<")p | + \ :nmap rT :!rake TEST=% +augroup END + +map rt :!ctags --extra=+f -R * +set scrolloff=2 "set foldmethod=syntax "let ruby_no_comment_fold=1 "let c_no_comment_fold=1 +set ruler +set laststatus=2 +set statusline=%t%(\ [%n%M]%)%(\ %H%R%W%)\ %(%c-%v,\ %l\ of\ %L,\ (%o)\ %P\ 0x%B\ (%b)%) +set lines=40 +set columns=80 + +"match ExtraWhitespace /\s\+$/ +"match ExtraTabs /\t\+/ +" +"highlight ExtraWhitespace ctermbg=darkgreen guibg=lightgreen +"highlight ExtraTabs ctermbg=red guibg=red +let ruby_space_errors = 1 command! -nargs=? -range Align ,call AlignSection('') vnoremap a :Align @@ -89,3 +137,5 @@ function! AlignLine(line, sep, maxpos, extra) let spaces = repeat(' ', a:maxpos - strlen(m[1]) + a:extra) return m[1] . spaces . m[2] endfunction + +setlocal spell spelllang=en_us