10 kick-ass Vim tips
Here are 10 Vim tips that I think you should know about (if you use Vim).
The super star and sharp
In normal mode you can use * and # to search for a word under the cursor. More info in Vim tip 1 Simple completion in any textHit CTRL-N once in insert mode and it will try to complete the current word with the first match in the current file. CTRL-P does the same thing but searches backwards. More info in Vim tip 11 The .Type . in normal mode to repeat last change, this is super useful when doing a receptive task. More info in Vim documentation The % keyYou can use the % key to jump to a matching opening or closing parenthesis, square bracket or a curly brace. Insanely useful when programming. More info in Vim tip 6 Indent using == and =When working with source code it is very nice to work with indented code. To indent the current line issue == in normal mode. Use Shift-V to go into visual mode, select a couple of lines and do = to indent them. More info in Vim tip 83 Undo and redoYou can use u to undo the last change. CTRL-R redoes a change that has been undone. U returns the current line to its original state. In Vim 7 you can use g- or g+ to go between text-states. To go to a text state 1 minute earlier, you can use:
More info in Vim tip 39 Incremental searchThere is a really neat search-option (Firefox users will love this tip). When you search (for example, using /), the matches will be shown while you type. To turn this option on, type following:
More info in Vim tip 13 Highlighting all the search pattern matchesTo highlight all the search pattern matches in a file set the following option:
To disable the highlighting temporarily, use:
More info in Vim tip 14 Turn off auto-indent when pasting textType in:
Now you can use <F3> to toggle between paste mode (and no paste mode). When in paste-mode auto indent will be turned off. This is very useful when pasting text that's already indented. More info in Vim tip 330 Don't repeat yourself - record your actionsTo start recording, press qa in the normal mode, this will save your recording in the a register. Now do your actions. After you are done, stop recording by issuing q in normal mode. To replay your recording issue @a in normal mode. This is really useful when doing some complex repeating tasks. More info in Vim tip 144 Your tips?You are welcome to post a comment about your favorite Vim tip.
Tips
·
VIM Editor
•
17. Feb 2007
|
|