tags:

views:

158

answers:

4

Hi all

Is there any way or tools to fold function in vim,like Visual Studio or Eclipse?

Best Regards,

+1  A: 

yes, it is bound to the 'z' key, e.g. zO opens all folds. see ":help fold" in vim for more information. You can do folding according to very simple rules, like indentation, or according to the code syntax.

Bullet Tooth Tony
+4  A: 
    Vim folding commands
---------------------------------
zf#j creates a fold from the cursor down # lines.
zf/ string creates a fold from the cursor to string .
zj moves the cursor to the next fold.
zk moves the cursor to the previous fold.
zo opens a fold at the cursor.
zO opens all folds at the cursor.
zm increases the foldlevel by one.
zM closes all open folds.
zr decreases the foldlevel by one.
zR decreases the foldlevel to zero -- all folds will be open.
zd deletes the fold at the cursor.
zE deletes all folds.
[z move to start of open fold.
]z move to end of open fold.

Source: vim docs.

codaddict
+1  A: 
:set foldmethod=syntax

should fold all functions and other blocks automatically, if you have syntax file for your language.

Paul
+2  A: 

Vim has excellent folding support. There is good documentation in the vim help system. Just open vim and do

:help usr_28.txt

After reading that you can also read

:help folding

for some more information.

Neg_EV