Wednesday, 24 February 2010
VIM Folding Away Unwanted Text/code
I've only just started using folding but how did I live without it before and it's so EASY! You make sections of the code you are uninterested in "disappear" with a fold or several folds. Of course many editors have folding but VIM combines folding with the power of its motion commands, you can even use regex!
" folding : hide sections to allow easier comparisons
zf} : fold paragraph using motion
v}zf : fold paragraph using visual
zf'a : fold to mark
zo : open fold
zc : re-close fold
:help folding
the folds I used
a) move to beginning of code I wish to work on and everything before
zf1G : fold all lines from current line to beginning of the file
a) move to end of code I wish to work on and everything after
zfG
zf} : fold paragraph using motion
v}zf : fold paragraph using visual
zf'a : fold to mark
zo : open fold
zc : re-close fold
:help folding
the folds I used
a) move to beginning of code I wish to work on and everything before
zf1G : fold all lines from current line to beginning of the file
a) move to end of code I wish to work on and everything after
zfG
Labels: folding, matchit.vim
Monday, 22 February 2010
Matching html/xml/script tags with matchit.vim
It is incredibly useful to be able to match tags in tangled PHP,Javascript and HTML files this is possible with the plugin matchit.vim. You will already know that Vim matches or jumps to a matching parenthesis ({{ , with matchit.vim you can jump to a matching tag.
Recently I need to configure it so that it would match tags in html files with the arbitrary extension index.raa
I achieved this by adding *.raa to the following line
au BufNewFile,BufRead *.html,*.htm,*.shtml,*.stm,*.raa call s:FThtml()in filetype.vim
but that's not upgrade safe so instead create
a subdirectory ftdetect in your vim folder
and create a file (in my case)
raa.vim containing just one line
au! BufRead,BufNewFile *.raa set filetype=raa
Labels: matchit.vim
Subscribe to Posts [Atom]