Longwood University Department of Computer Science Advanced Computing Lab

17 Sept 2014

What is Vim?

Vim is a text editor which you can use to create and manipulate files. Vim is entirely text/command-line based, which gives it several advantages over graphical editors such as Eclipse or gedit. In particular, Vim can easily be used over an SSH connection and only takes a few seconds to load.

How to configure Vim

Vim provides many advanced features, but many of them are turned off by default. If you want to enable them, you need to create a file named .vimrc in your home directory. You can then type vim commands into this file. Anything you put in .vimrc will be automatically run every time you open vim.

Syntax Highlighting

One of the most useful features of vim is the automatic vim syntax highlighting. You can turn syntax highlight on with the :syn on command and turn it back off with the :syn off command. By default, the syntax highlighter assumes you have a window with a light background. To have it use colors that show up nicely on a dark screen, you should add "set bg=dark" to your .vimrc file.

Enabling Plugins

In addition to the built-in features, vim comes with a set of plugins that can extend its functionality. In our lab, these plugins are disabled by default. To turn them on, you need to set the "load_plugins" or "lpl" option by adding set lpl to your .vimrc file.

Spellcheck

Vim has a really neat spellchecker which can (among other things) check the spelling in the comments of your C++ or other programs. To enable spell checking, all you have to do is set a language. To do this, add this to .vimrc:

setlocal spelllang=en_us

Vim has many other features -- too numerous to list here. A good place to learn more about vim is Learn Vimscript the Hard Way. There is also a very useful Vim cheat-sheet.