" cygwin.vimrc - Vim Configuration File " Author: Sean B. Palmer, inamidst.com " From various sources noted inline " Whitespace Settings " Cf. http://www.vim.org/tips/tip.php?tip_id=12 set expandtab set shiftwidth=3 set tabstop=4 set textwidth=79 " @@ A way to toggle this, or, rather, wrap, off/on " Movement Settings " Cf. The standard .vimrc example " Cf. http://www.dotfiles.com/files/9/247_vimrc " Cf. http://www.stripey.com/vim/vimrc.html set backspace=indent,eol,start set matchpairs+=<:> " Bounce 'twixt angled brackets too set scrolloff=1 " Makes it harder to lose stuff set whichwrap=b,h,l,<,>,~,[,] " Actually *backspace* across lines... nnoremap dh " Display Settings " Cf. http://deleurme.com/_vimrc.html " Cf. http://vimdoc.sourceforge.net/htmldoc/options.html set background=light set hidden " Natural buffer display set showcmd " Whoo! set shm+=I " Remove start up message set title " Puts information in the term title bar set ttyfast " Makes things faster, I guess " Todo: @@ Get this to work: " set titlestring="VIM [+=-] (path) filename" " Miscellaneous Settings " Cf. http://fly.srk.fer.hr/~kmarzic/files/.vimrc set comments=s1:/*,ex:*/,://,b:#,:%,:XCOMM,n:>,fb:- set directory=/var/tmp,/tmp " No messy swap files set encoding=utf-8 " But of course. @@ fileencoding set incsearch " Set incremental search, a la Firefox Ctrl+F set noerrorbells " Ding dong bing blam bong set ruler " Displays the position in the file set runtimepath=~/config/vim,$VIMRUNTIME set shell=zsh " Because it's awesome " Todo: " @@ Keys to toggle list/nolist? " @@ set insertmode - Tempting, but still... " Dictionary and Completion Settings " set dictionary=~/config/vim/dict " set complete=k~/config/vim/dict " Syntax Highlighting if has("syntax") " @@ Or... well, just normal grey on black is nice too highlight ModeMsg cterm=bold ctermfg=Yellow ctermbg=Blue endif " Cf. http://fly.srk.fer.hr/~kmarzic/files/.vimrc " @@ Would be nice to include the modification character autocmd BufEnter * let &titlestring="vi - " . expand("%:p:~") " Automatically chmod 755 known executable files autocmd BufWritePost *.cgi,*.py,*.sh !chmod 755 % " Archive the .vimrc to inamidst " @@ Way to set variables, e.g. $INAMIDST autocmd BufWritePost vimrc !cp ~/web/inamidst.com/www/config/vimrc ~/.vimrc " Save using Ctrl+S " In .zshrc: stty start "" " @@ Use :w again? nnoremap :update inoremap :update " Quit using Ctrl+Q " In .zshrc: stty stop "" " @@ What about using :wq again? nnoremap :confirm qa inoremap :confirm qa " Move lines up/down with Ctrl+J/N " @@ Ctrl+J/N is not natural. Ctrl+Up/Down doesn't work, though inoremap ddkkpi inoremap ddpi " @@ ,p for entering a new paragraph neatly " Upload to inamidst if possible nnoremap :!bin/upload /% inoremap :!bin/upload /% " Cut line and Paste line with Ctrl+K and Ctrl+U " Two registers: p is temporary, q is accumulative autocmd BufEnter * let @p = "" autocmd BufEnter * let @q = "" inoremap "pdd:let @q = @q . @p:let @p = ""i inoremap q:let @q = "" " Have Q reformat the current paragraph, or selected text " Cf. http://www.stripey.com/vim/vimrc.html nnoremap Q gqap vnoremap Q gq " Delete the line above if it's empty " nnoremap ,, :.-1g/^$/d " Include a file from ~/config/vim/inc command -nargs=1 Inc :read ~/config/vim/inc/ | :.-1g/^$/d " Pipe the current buffer into a shell command command -nargs=+ Pipe :%write! /tmp/vim.pipe | \ :!echo; cat /tmp/vim.pipe | ; \ rm -f /tmp/vim.pipe " Grep the current buffer and add line numbers command -nargs=+ QuickGrep :%write! /tmp/vim.grep | \ :!echo; egrep -n /tmp/vim.grep; \ rm -f /tmp/vim.grep " Grep to a new buffer with :Grep " @@ Split this into a module function GoToLine(mainbuffer) let linenumber = expand("") silent bd! silent execute "buffer" a:mainbuffer silent execute ":"linenumber silent nunmap endfunction command -nargs=1 GoToLine :call GoToLine() function GrepToBuffer(pattern) let mainbuffer = bufnr("%") silent %yank g enew silent put! g execute "%!egrep -n" a:pattern "| cut -b0-79 | sed 's/:/ /'" silent 1s/^/\="# Press Enter on a line to view it\n"/ silent :2 silent execute "nmap 0:silent GoToLine" mainbuffer "" " silent nmap :bd! endfunction command -nargs=+ Grep :call GrepToBuffer() nnoremap :Grep inoremap :Grep " Switch Buffers With Ctrl+B " @@ Split this into a module function GoToBuffer() let buffer = expand("") silent bd! silent execute "buffer" buffer silent nunmap endfunction function BuffersToBuffer() let oldbuffer = bufnr("%") silent redir @b silent buffers silent redir END enew silent .s/^/\="# Press Enter on a buffer to view it\n" . @b/ silent %g/^$/d silent %s/^ *// silent command -nargs=1 GoToStarting :call search("^", "w") silent execute "GoToStarting" oldbuffer silent delcommand GoToStarting silent nmap 0:silent :call GoToBuffer() endfunction command -nargs=0 Buffers :call BuffersToBuffer() nnoremap :Buffers inoremap :Buffers " [EOF]