More vim tips from linux.com: Folding fun
By BiffsterLinux.com 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.
Linux.com 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.





Post a Comment