Miscellaneous stuff from my .vimrc file

Some more VIM goodies that have accumulated in mv .vimrc over the years:

Switch between :split and :vsplit windows using CTRL+hjkl:

map <c-J> <c-W>j<c-W>_
map <c-K> <c-W>k<c-W>_
map <c-H> <c-W>h<c-W>_
map <c-L> <c-W>l<c-W>_
set wmh=0

Nicer color scheme: brighter comments, more contrast for search highlight. Intended for systems that use the light-on-dark scheme.

hi Comment ctermfg=darkcyan
hi Identifier ctermfg=lightgreen
hi PreProc cterm=underline
hi Search ctermbg=darkblue cterm=underline

Triple <esc> removes the annoying search highlight created by incremental search

:nnoremap <silent> <esc><esc><esc> :noh<cr>

In PHP files, shift-K searches word under cursor in online manual

autocmd FileType php
    \ nmap <s-k> <s-k><cr> |
    \ set keywordprg=php_lookup.sh

(php_lookup.sh is a shell script or batch file on the path that opens a web browser on the function’s manual page, e.g. for Mac OS X: open http://de2.php.net/$1)

In PHP files, ctrl-B checks PHP syntax

autocmd FileType php map <c-B> :w !php -l<cr>

Activate syntax highlighting for .rhtml files (put eruby.vim to ~/.vim/syntax/eruby.vim)

autocmd BufNewFile,BufRead *.rhtml set syn=eruby

See also: VIM: Switching off auto-indentation, VIM: Setting custom tab behaviour for some filetypes, VIM: Quick autocompletion

This entry was posted in General. Bookmark the permalink.