You can find this descendant of Vi on your Linux system by typing alias vi and pressing Enter. You'll probably get alias vi='vim'. For a comprehensive look at the differences between vi and vim, you can enter :help differences at the vim command line.
New features include multiple windows, syntax highlighting, multiple levels of undo, and color themes. All of these improvements are made possible by the use of vim plugins.
Plugins are nothing more than scripts that are written for vim. When executed, vim checks /etc/vimrc or ~/.vimrc (if it exists) to get a list of directories that contain plugins. Each .vim file in those directories is then "sourced" -- read in as a list of instructions to vim. These instructions may be carried out automatically, as in the case of syntax highlighting plugins, or may provide you with additional capabilities that you can take advantage of with a pre-defined key combination, for performing a spell-check, for instance. You can also enter :source <path>/<plugin> to manually source a plugin for testing or temporary use.
The ftplugin directory (usually under /usr/share/vim/<version>) contains plugins that are sourced when particular types of file are opened. They contain key mappings and syntax highlighting rules for HTML, Java, C, and other programming languages. For more information about them, type at the vim command line :help filetype.
Some plugins are installed with your Linux distribution; some you can add through your package manager. Check the /usr/share/vim-scripts/plugin directory if it exists on your system. The best source for additional plugins is vim online.
Once you have downloaded a new plugin, there are several ways to make it available to vim.
:source <path/plugin> command. If you manually download and copy a plugin to a directory that is not sourced in /etc/vimrc or ~/.vimrc, then you will have to source it before you can use it.Some plugins can also be called with vim <path/plugin>, or with a shell script from the Linux command line.
Most plugins come with extensive documentation. If, for example, you download the file newplugin.vim, there might also be a corresponding newplugin.txt file. You can copy newplugin.txt to /etc/vim/doc or ~/.vim/doc, then source the help file with :helptags /etc/vim/doc/ or helptags ~/.vim/doc from the vim command line. This allows you to type :help newplugin to access the newplugin.txt helpfile.
Since vim plugins are basically shell scripts, you can create plugins for just about any purpose you can imagine. For more information on writing your own plugins, enter :help write-plugin from the vim command line.
Among the many good plugins available for vim (including an Emacs emulation plugin), here are nine for you to try.
Tutor
Tutor is generally distributed along with vim. You can call it from the command line with vimtutor. This plugin is a good tutorial for the beginning vi user, as it begins with the basic movement keys and continues through editing, command execution, and creation of a personal vimrc file. Even if you're familiar with vim or vi, you'll probably run across something you've forgotten, or never known.
Vimspell
Vimspell is distributed with vim, beginning with version 6.3. It allows you to run your text file through the aspell or ispell spelling checkers, with any resulting errors highlighted within vim. Vimspell works like most other spell-checkers, allowing you to select alternate spellings, skip words, or add words to your personal dictionary.
Explorer
Distributed with vim, Explorer allows vim to display a directory tree when a directory, as opposed to a specific file, is given as an argument to vim. You can then navigate the directory tree within vim and select a file for editing.
Although vifm.vim is available as a standalone file manager, you can copy it to your plugin directory to allow both vifm and vimdiff to be used within a normal vim editing session.Universal text link allows you to set hyperlinks within your text documents. Hyperlinks can be used to start applications, open related documents, or bookmark parts of your text document.
Calendar adds a calendar display to the side or bottom of your vim session. You can attach notes to each date of the calendar.
The Most Recently Used file list allows you to type :MRU at the command line to display a list of those files most recently edited. This is useful for system administration, especially when you want to see what you've been up to as root.
If you find the filetype plugins helpful, then winmanager may also be of real value to you. Entering :WMToggle at the vim command line opens two small panes to the left of your text editing session that display a directory browser and a buffer browser. The result is a small, fast, powerful integrated development environment that provides syntax highlighting and key mappings customized for specific languages. Ctrl-w allows you to use the h, j, k, and l keys to move between windows as you would between characters in vi/vim. You can combine other plugins with winmanager, including a tag explorer, which you can access with the Ctrl-n key combination from the directory explorer window.
Yes, Tetris is available for vim, with high score and Traditional or Rotating game play. In Rotating, the columns continuously move left, off the screen, and back to the right again. If for no other reason than to play Tetris on an ASCII console, you should try this out.
In addition to plugins, there are many more features and versions of vim available. Some that are worthwhile are:
Gvim -- Known as the "official" vim GUI session, gvim is excellent for beginning to experienced vim users. Gvim allows you to use a scrollbar, mouse, menus, and cut and paste in a GUI-friendly manner without sacrificing any of the vi/vim keystrokes or conventions.
Cream -- Another X-capable vim session, aimed specifically at the beginning vim user. Cream includes more formatting options and extensive helpfiles.
Vigor -- It's "Clippy" for vim. Best for the vi-phobic.
The growth of vim is staggering. There are currently more than 1,300 plugins available at vim online, some of which are bound to make your life easier or a little more fun. Taking advantage of such a wealth of hard work and talent is more than just good fun; it's good sense.
Michael M. Murphree has been a Linux user for more than a decade. He administers high-performance computational clusters and is certified LPIC-2 by the Linux Professionals Institute.
Note: Comments are owned by the poster. We are not responsible for their content.
I kinda like that edit program in MSDOS... I wonder if Wine can run DOS programs?
I have never really understood what people mean when they say "increase in programming productivity" when pushing Vim to newbies. Most of the really useful programming plugins are really only useful/intuitive with the GUI version of Vim. And a lot of the features that, at least in my case, increase programming productivity are either poorly implemented or missing.
I use Eclipse for my projects. I use vim whenever I need to drop to a command line and have to use a text editor. I use Emacs whenever I find myself on a command line and need a more intuitive editor, editing a large file and then doing regex-based search and replace at least is faster under Emacs. Personally I don't recommend Vim or Emacs to newbies because they will likely spend most of their time figuring out how to work with the editor instead of actually writing code (which should be their focus as newbies). And personally I don't use Vim or Emacs for very large projects because they can be very difficult to manage under either editor.
As for experienced programmers coming from Windows to Linux/Unix, I don't see the point of recommending vim to them either. Some of the things I look for in a text editor for programming are:
Of all the editors/IDE I've tried (including Vim, Emacs, Komodo, JEdit), only Eclipse has come close to my expectations. Emacs comes a close second.
The only feature I want
Posted by: Anonymous Coward on August 30, 2005 11:41 PM#