O'Reilly logo

Hacking Vim 7.2 by Kim Schulz

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Folding

Often, when you work with large files, especially code, it can be hard to get a good overview. In Vim, there is a special feature that helps you get around this—folding text blocks into folds. In this recipe, we will look at how to use folds to make your code easier to overview.

A fold is a way of folding a range of lines (for example, a function scope) into one single line without losing the contents. An example could be the following code:

function myFunction(){
   var a = 1;
   var b = 0;
   var c = a+b;
   return c;
}

If this is folded, then it could be set to look like this:

+-- 6 lines: function myFunction(){ ------------------------------

In this case, the folding follows the syntax of the code and uses the { } to figure out where to do the folding. ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required