Skip to content

Setting Up vim on PE Hosts

Vim Configuration

Like many other Unix programs, you can configure your preferences by creating an rc (run commands) file in your home directory. These rc files will be read by the corresponding programs and executed line-by-line as if the text is entered into the program through a keyboard. You can view an rc file as a script that will be executed automatically whenever a program starts.

For vim, the rc file is called .vimrc. The . in the front of the file name carries a special meaning in Unix. It means that this file is hidden -- you won't see it when you ls. Hiding the run command files prevent your home directory from being cluttered. To tell ls to show the hidden files, use the -a flag

1
$ ls -a

We have created a .vimrc file, with CS1010 defaults, for your use. This is the basis upon which you can build your own configuration.

To copy this file to your home directory on the PE nodes,

1
$ cp ~cs1010/.vimrc ~

You can ask vim to automatically back up the files that you edit. This has been a lifesaver for me on multiple occasions.

The default .vimrc contains the following two lines:

1
2
set backup
set backupdir=~/.backup

This causes vim to save the previous version of every file you edited in a backup directory at location ~/.backup. You need to create this directory, however, by

1
$ mkdir -p ~/.backup

Now, if you made changes to a file that you regretted, or if you accidentally deleted a file, you can check under ~/.backup to see if the backup can save you.

Vim Plugins

CS1010 provides a minimal set of vim extensions by default for your labs and practical exams. See the article on vim plugins for details.

Additional vim extensions are installed under ~/.vim. To install these "official" CS1010 vim extensions, you can copy the .vim from cs1010's home directory to your home directory. On the PE host, run:

1
2
mkdir -p ~/.vim
cp -r ~cs1010/.vim/* ~/.vim

You can test out the different color schemes according to the instructions to check if you have set up the plugins correctly. The default CS1010 .vimrc uses the molokai color schemes.