Effective Use of an Editor (vim)

Table of Contents

1. Vimtutor
2. Some Vim Tricks
3. Customising Vim
4. Assessment
5. Final Words
6. Emacs tips

Note

Virtualbox is not used for this lab. You can use any machine which has the vim program installed, such as your local workstation.

Today’s lab is intended to be of the self-guided variety. The reason this lab is included in the schedule this year is to ensure that you have a certain degree of productivity in the environment we provide to you. There are a number of features any Unix power-user or administrator needs to have in their chosen editor in order to do things quickly.

Vim is a member of vi family. Due to the licensing of the original vi editor, all vi work-alikes on Linux systems now tend to be a subset of vim or another vi-like editor, such as nvi or elvis.

The reason I want to teach you vim here is because you already have some (albeit minimal) exposure to GNU Emacs, and I wish you to train your mind to be open to different approaches, and of not fearing things because they are different or unfamiliar. People with some fluency in vi already will likely find something useful in this lab also. If you are already well achieved in using vim, you can do the assessment in Section 4, “Assessment” directly.

1. Vimtutor

You can complete this section on your local workstation. Because we aren’t using Client1 for this lab, you can work on this lab while you work on another lab at the same time, in order to schedule your time more effectively.

The default behaviour of vi can be rather awkward for the beginner, so I recommend you put the following in your ~/.vimrc to remove some of the awkwardness of vi from vim before you dive into the tutorial. You will likely need to create this file. Since you have not used vim yet, you may prefer to use nano to edit the file.

set nocompatible

When you have made the change, from a terminal, run the command vimtutor. This will start up vim on a copy of a tutorial file. This file has teaching instructions inside it which will get you well on your way to mastering the basics. Follow the instructions till you have completed the tutorial.

Note

At the end of the tutorial, you don’t need to change ~/.vimrc as suggested. You may like to read Section 3, “Customising Vim” to find some suggestions as to what you can put in your ~/.vimrc instead, if you are interested.