7 Relatively Unknown But Very Powerful Vim Features
By Daniel Miessler on January 14th, 2007: Tagged as Linux | Programming | Vim
I’m a bit obsessed with mastering vim. I kind of feel like I’m killing kittens every time I do something inefficiently. I know plenty of commands, but you don’t truly know a command (like in the Biblical sense) until you find yourself using it without thinking. I am on a continuous mission to raise the number of commands that I know in this way. This post is my latest attempt to lock in some good ones.
I compiled this list from a wide range of other collections online, including my own tutorial, contributions from friends, and this article, which is currently my favorite stand-alone introduction to vim.
- View/edit two files at once.
:vsplit foo.txt
You can then switch between the windows with ctrl-ww. - Run an external command and capture the output.
:r ! date - Repeat your last command by typing "." (a period). So elegant.
- Auto-complete text using
ctrl-n. If the text is elsewhere in your document,vimwill know and try and complete it for you. - Hide blocks of text by "folding".
Highlight the area you want to fold (using
vorV) and presszf. Think "f" for fold. To "open" it, presszo.
- Quickly switch between Unix and Windows file formats.
Type
:set filetype=Unixor:set filteype=dosrespectively. - More easily edit code by enabling syntax highlighting.
Create a file called
~/.vimrcand putsyntax onin it.
:
