Take advantage of the new features of open source vim 7.0

In this tip, Vincent Danen tells you about the new features of open source text editor vim 7.0.

A few months ago, the latest major version of vim, which has been in development for a few years, was released. The new vim 7.0 still retains the same interface and commands as previous vim versions, but contains a number of new and very useful features.

The first is spell-checking. Those using vim to edit text documents like man pages or as an editor for an e-mail client (i.e., mutt) will really appreciate the fact that you can now perform spell-checking within vim.

To enable the feature, type :set spell in command mode. Any spelling mistakes will be highlighted red on the screen and any capitalization errors will be noted in blue. To jump forward and backward to misspelled words use [s and ]s respectively. [S and ]S can be used to omit capitalization errors and just jump to words spelled wrong.

If vim highlights a correctly spelled word, such as your name or company name, you can use the zg command to add the word to the spelling list. Likewise, when you have the cursor on a misspelled word, type z= to obtain a list of possible correct spellings.

In order to use the zg command (and the zw command to reverse additions made by zg), you'll need to edit your ~/.vimrc file to add the following:

set spellfile=~/.vim/spellfile.add
set spelllang=en_us

The first sets the location of where words added by zg get placed. The second ensures your chosen language for spelling is always set.

Another new option is vim's support for tabs. This is quite handy when you want to edit multiple files at one time—a feature that is nearly standard in most GUI text editors these days.

To open a file in another tab, use :tabe filename in command mode. At the top of the screen is the tab "bar" which lists the different files that are opened in other tabs. The highlighted file is the one currently being edited. Use :tabp and :tabn to move to a previous or next tab respectively, or :tabr and :tabl to go to the beginning and last tabs.

Other improvements to vim include code completion for a number of programming and scripting languages, undo branches for deletions, the ability to edit remote files and view remote directories, improved Unicode support, and more. If you're currently using vim, you'll definitely want to upgrade to vim7.

Delivered each Tuesday, TechRepublic's free Linux NetNote provides tips, articles, and other resources to help you hone your Linux skills. Automatically sign up today!


Vincent Danen works on the Red Hat Security Response Team and lives in Canada. He has been writing about and developing on Linux for over 10 years and is a veteran Mac user.


Editor's Picks