" General options set background=dark set backspace=indent,eol,start set cindent autoindent set cinoptions=t0,+4,(4,u4,w1 set confirm set encoding=utf-8 set expandtab set incsearch set mouse=a set nocompatible set nohlsearch set number set ruler "set shiftwidth=8 set showcmd set showmatch set showmode "set softtabstop=8 "set tabstop=8 set tags=./tags,tags,/usr/src/sys/arch/amd64/tags,/var/db/libc.tags set term=screen-256color set ttyfast colorscheme eink source /usr/share/vim/vim73/ftplugin/man.vim " ^n/^p to switch between tabs nnoremap :tabnext nnoremap :tabprevious " switch between relative and absolute number nn :setlocal relativenumber! relativenumber? nn :setlocal number! number? " toggle search highlighting (off by default) nn :setlocal hlsearch! hlsearch? " indent the current file with indent(1) nn ,i :%!indent -st " make clean nn ,c :silent! make clean \| redraw! \| cw nn ,t :silent! make tags \| redraw! \| cw " mk options nn ,M :!mk nn ,C :!mk clean nn ,N :!mk nuke " KNR mode and highlight lines > 80 chars highlight OverLength ctermbg=red ctermfg=white guibg=#592929 match OverLength /\%81v.*/ let c_space_errors=1 " line set cinoptions=:0,t0,+4,(4 " fix glitches in certain terminals " backspace imap ^? ^H " ctrl up and ctrl down in tmux "if &term == "screen" " set t_kN=^[[6;*~ " set t_kP=^[[5;*~ "endif " spell checking " text & mutt files au BufNewFile,BufRead /tmp/mutt*,/tmp/cvs*,*.txt set tw=72 noai noshowmatch au BufNewFile,BufRead /tmp/mutt*,/tmp/cvs*,*.txt setlocal spell spelllang=en_us au BufNewFile,BufRead /tmp/mutt*,/tmp/cvs*,*.txt syntax off " git commits au BufNewFile,BufRead *.git/COMMIT_EDITMSG set tw=72 noai noshowmatch au BufNewFile,BufRead *.git/COMMIT_EDITMSG setlocal spell spelllang=en_us " f7 toggles spelling on/off nn :setlocal spell! spell? " view binary files as hex " Convert to hex and back; does not save changes nn :%!xxd -g 1 nn :%!xxd -g 1 -r " makefile magic " compiler stuff let g:compiler_gcc_ignore_unmatched_lines=1 let mapleader=',' " quickfix :make nmap m :wa:silent! make \| redraw! \| cw vmap m :wa:silent! make \| redraw! \| cw " handy shortcuts map h :ccl map s :cw map l :cl " jump between messages map n :cn map p :cp " format selection map f :!fmt " @c comment, @u uncomment, @p print function name let @u='0xx$xx^[' let @c='I/*^[A*/^[' let @p='ofprintf(stderr, "%s\n", __func__);^[' function! s:ExecuteInShell(command, bang) let _ = a:bang != '' ? s:_ : a:command == '' ? '' : join(map(split(a:command), 'expand(v:val)')) if (_ != '') let s:_ = _ let bufnr = bufnr('%') let winnr = bufwinnr('^' . _ . '$') silent! execute winnr < 0 ? 'new ' . fnameescape(_) : winnr . 'wincmd w' setlocal buftype=nowrite bufhidden=wipe nobuflisted noswapfile nowrap silent! :%d let message = 'Execute ' . _ . '...' call append(0, message) echo message silent! 2d | resize 1 | redraw silent! execute 'silent! %!'. _ silent! execute 'resize ' . line('$') silent! execute 'autocmd BufUnload execute bufwinnr(' . bufnr . ') . ''wincmd w''' silent! execute 'autocmd BufEnter execute ''resize '' . line(''$'')' silent! execute 'nnoremap r :call ExecuteInShell(''' . _ . ''', '''')' silent! execute 'nnoremap g :execute bufwinnr(' . bufnr . ') . ''wincmd w''' endif endfunction command! -complete=shellcmd -nargs=* -bang Shell call s:ExecuteInShell(, '') cabbrev shell Shell " command! -bang Fixmake " nmap b :wa:silent! !go build \| redraw! \| cw " nmap o :wa:silent! !go fmt \| redraw! \| cw " nmap t :wa:silent! !go test \| redraw! \| cw :ab #d #define :ab #i #include autocmd FileType make setlocal noexpandtab autocmd FileType c setlocal noexpandtab autocmd FileType cc setlocal noexpandtab autocmd FileType go setlocal noexpandtab autocmd FileType python setlocal shiftwidth=4 softtabstop=4