More vim tips from Folding fun continues their Vim tips series with “Folding fun”:

Let’s start with some simple folding actions. Pick a text file, preferably a longer one like your xorg.conf, or just about any text file that’s too big to fit on the screen by itself. Open it in Vim, and place the cursor at the beginning of a paragraph. Make sure you’re in normal mode, and type zf2j. After you press j, Vim will create a fold covering three lines — the line you started the fold on, and the next two lines. If you’re familiar with Vim’s movement commands, you know that the command 2j would usually tell Vim to move down two lines. Vim uses the same movement commands to define folds.Folding also works in visual mode. If you enter visual mode using v or V, then select a few lines of text using the movement keys, and type zf, Vim will create a fold comprising those lines. is going to make an advanced vim user out of me yet. These tips and tricks are invaluable. vim is an amazing text editor once you have time to sit down and work out what functions it has and how one goes about using those functions.

Related posts:

  1. Vim tips: Moving around using marks and jumps
  2. vim plugins
  3. Linux command line tips

Comments are closed.

Profile picI am a 40-ish uber-geek, Daoist and family man. Blessed to have one incredible wife and three wonderful kiddos. Dao has been kind to me.

May 2006
« Apr   Jun »
QR Code
Top categories