Was just reading this article on linux.com about some guy’s sysadmin toolbox. Yeah, the tools were ok and nothing much different from what I use except for some of the desktop-ish stuff he uses. What got me though was the first comment that was made. Vim has text folding? I had no idea. That totally rocks!

One thing I appreciate about the two IDE’s I use (Komodo and Zend Studio, although Komodo does this one thing nicer) is code folding. I love being able to fold code and get it out of the way. The fact that I can do this in vim, with anything is really really cool.

Quick step by step here to get the basics (use “:help folding” to get a really large rundown on all the stuff you can do): Use “V” to visually highlight the lines you want to fold (this is in command mode, BTW) then use “zf” to fold them into one line (the “z*” commands seem to be relevant just for folding). You’ll get something like this:

+----  8 lines: if ( $wgCommandLineMode ) {--------

You can use “zo” to open the fold, which just expands it. You can then use “zc” to close the fold again (good for quick peeks), without having to re-highlight the block. As well, just about anything you do on the line that is the fold marker (as shown above) will expand it… ie. hitting “$” to get to the end of the line will do it, hitting the right arrow will do it, etc. The nice thing is you can “zc” the fold while you’re anywhere in the fold.

I really need to use vim more and remember all the bloody commands. I’ve been using joe for so long that, although I can use vim quite well, I don’t have it customized enough and can never remember simple commands like page-up/down, etc. Maybe I should remove joe from everything and force myself to use vim (I did that with OS/2 when I first started learning Linux and look at me now!)

Oh, another article that I haven’t read fully yet but that looks good is Seven habits of effective text editing written by the vim author, Bram Moolenaar, himself.

Share on: TwitterLinkedIn


Published

Category

Linux

Stay in touch