Vim logo vim online Vim Book Ad

 Tip #240: Hideall for Vim

 tip karma   Rating 10/6, Viewed by 667 

created:   May 2, 2002 8:28      complexity:   intermediate
author:   Wenzhi Liang      as of Vim:   6.0

Xemacs has a hide all function which can make all the function in your C file a fold and close them. And here is something small to achieve similiar under Vim.

func! HideAll()
   syn region myFold start="{" end="}" transparent fold
   syn sync fromstart
   set foldnestmax=1
   set foldmethod=syntax
endfunc

amenu Whatever.Hide\ all :call HideAll()<CR>

 rate this tip  Life Changing Helpful Unfulfilling 

<<Scroll using arrow keys like browser: map shift-up and shift-down | "Hide" Folding Markers >>

Additional Notes

[email protected], May 2, 2002 13:06
It works fine in version 6.0.  But in version 6.1, it is really ugly.
Suppose, you have the following Java
public class Hello {
[email protected], May 2, 2002 13:09
I accidently cancel last note.  Sorry about this.
Suppose, you have the following java file:
public class Hello {
   public void setter() {
   // do something ...
   }
}
In 6.0, you will the indivisual method name (i.e., you will see the Hello and setter.  So you can unfold the level you want.  But in 6.1, you only see only big level that is the Hello.  If you want to the method name -- setter, you have to unfold the Hello first.  This is really inconvenient.  I am not sure this is a "new feature" or simply a bad bug.
[email protected], May 3, 2002 3:19
No they both work for me. I hav 6.0 and 6.1 running side by side and doing exactly the same thing.

Maybe you forgot :set foldnestmax=2 ???
[email protected], May 3, 2002 14:44
Yes, it works fine after I set the foldnestmax=2.  Thanks a lot.
[email protected], September 10, 2002 18:33
That's really neat. Now how do I get it to automatically apply to any .c .C .cc .cpp file I open? And is doing that a good idea?
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to [email protected] after searching the archive. Help Bram help Uganda.
SourceForge Logo