Vim Tips Wiki
Advertisement
Tip 519 Printable Monobook Previous Next

created 2003 · complexity basic · author Eric Boucher · version 6.0


If you are using Microsoft Visual Studio .NET for editing Visual Basic .NET files, the Window Form Designer Generated Code is folded by default. If you want to have the same nice feature when editing the same file in Vim, put this code in your vimrc file so you can switch between the folded and unfolded mode:

function! NetFold()
  set foldmethod=syntax
  syn region myFold start="#Region" end="#End Region" fold
  syn sync fromstart
  set foldcolumn=2
endfunction

function! NetUnFold()
  set foldmethod=manual
  set foldcolumn=0
  norm zE
endfunction

So when your are editing a *.vb file, you simply have to call the function like this:

:call NetFold()
or
:call NetUnFold()

Also, if you want that little function to be called automatically when you edit a *.vb file, put these two lines in your _vimrc file:

autocmd BufNewFile,BufRead *.vb setfiletype vb
autocmd BufNewFile,BufRead *.vb call NetFold()

Comments

:g/^#R/,/^#E/fo

Advertisement