vim Cheat Sheet

06 February 2017

vim Cheat Sheet

My all-time favourite commands for vim. Check out these classic hits.


Format/indent/pretty-print an XML document:

:%!xmllint --format %

Insert spaces instead of tabs (expandtab) when pressing the Tab key - how to switch on and off:

:set et
:set noet


How I set up my Vim ready to use:

  1. Install Vundle for managing Vim plugins

To install/manage plugins with Vundle:

  1. Add any plugins required into /.vimrc
  2. From Vim, type :PluginInstall.

To configure syntax highlighting for a file type/extension, add the following to your ~/.vimrc file:

au BufRead,BufNewFile *.adoc set filetype=asciidoc

Using Vim as a Java IDE

Install SpaceVim.


  • Install using the instructions at
  • If you installed vim using Homebrew, then the SpaceVim install script will install itself into your Homebrew install of Vim, so use that by setting an alias, e.g. alias vim="/usr/local/Cellar/vim/8.0.0604/bin/vim"
  • If colours don’t work on Mac, you need to disable “true colours” (??) - add this line to ~/.SpaceVim.d/init.vim: let g:spacevim_enable_guicolors = 0


  • Toggle file explorer (VimFiler) - F3