History Report a problem
Article Edit this page Discussion

Folding like in Visual Basic .NET

From Vim Tips Wiki

Jump to: navigation, search
 

Tip 519Previous TipNext Tip

Created: July 29, 2003 Complexity: basic Author: Eric Boucher Minimum version: 6.0 Karma: 7/11 Imported from: Tip#519


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()

[edit] Comments

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

Rate this article:

Share this article:

Hubs Highlights International Sites Wikia messages
Entertainment
Gaming
Cartoons & Comics
Science Fiction
Hobbies
Sports
See all...
Grand Theft Auto
Doctor Who
Legend of Zelda Wiki
Terminator Wiki
Everquest II Wiki
Mystery Science Theater 3000
German
Spanish
Chinese
Japanese
More...
Wikia is hiring for several open positions
Send this article to a friend
"Folding like in Visual Basic .NET"
 
 
Hi!

I thought you'd like this page from Wikia!

http://vim.wikia.com

Come check it out!
Send confirmation