Skip to content

7 Relatively Unknown But Very Powerful Vim Features

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.

  1. View/edit two files at once.: :vsplit foo.txt You can then switch between the windows with ctrl-ww.
  2. Run an external command and capture the output.: :r ! date
  3. Repeat your last command by typing “.” (a period). So elegant.
  4. Auto-complete text using ctrl-n. If the text is elsewhere in your document, vim will know and try and complete it for you.
  5. Hide blocks of text by “folding”. Highlight the area you want to fold (using v or V) and press zf. Think “f” for fold. To “open” it, press zo.
  6. Quickly switch between Unix and Windows file formats. Type :set filetype=Unix or :set filetype=dos respectively.
  7. More easily edit code by enabling syntax highlighting. Create a file called ~/.vimrc and put syntax on in it.