Friday, February 23, 2007

VIM - Advanced Tips

Here are some advanced tips I've learned from coworkers and working with VIM:

:%s *$==Delete end of line spaces
:'a,'bs/str1/str2/gReplace "str1" with "str2" from marker a to marker b
:%s/\(.*\):\(.*\)/\2:\1/gReplace the first field (\1) with the second field (\2) separated by the :
zfFold a selected block of code
zdUnfold a block of folded code
:makeRun Makefile
:w|makeWrite (save) current file and then run Makefile
:grep regexp filesFind regexp in files
:copenOpen quickfix list. Helpful after doing :make or :grep. Press Enter on entry in quickfix list to jump to that location
:ccloseClose quickfix list
:colderDisplay contents of previous quickfix list
:cnewerDisplay contents of next quickfix list
:!cmdRun cmd as if on command line. Example: :!ls
:bwClose current buffer
ctrl+oGo back once through visited lines
ctrl+iGo forward once through visited lines
:h topicGet help for topic

No comments: