Vim - The Linux editor
Text editors are almost as old as computers. They replaced the keypunch (initially still line-oriented) as a processing interface for computer programs and data. They also only enabled – mainly due to the former typewriter-like terminals – individual lines of text files to be changed. Not until the development of computer terminals did the first screen-based text editors gradually emerge. Such examples would be the mainframe program O26 (1967) and the unicode editor vi (1976), which is still included in the standard scope of many distributions.
Even today the function of text editors is to display the contents of text files so they can be edited. But modern programs come with numerous enhancements that make the job considerably easier for the user. These include search functions, automatic code completion, or the option of highlighting syntax. Vim is a favorite among the younger generation of users, offering a huge range of features and is compatible with various platforms.
What is Vim?
Since the aforementioned unicode editor vi wasn’t available for Amiga computers, the Dutch computer scientist, Bram Moolenaar developed the first version of Vim in 1988. The vi replica, Stevie, served as a basis for its GPL licensed open source work, which still bore the name Vi IMitation. The Amiga version followed in 1992 as an equivalent for Unix and MS-DOS. Around this time, the acronym of the text editor also received its present name: Vi IMproved. Since then, the editor has undergone various developments, which is why it’s considered one of the most complete solutions in this field. Vim works in text mode on each terminal, whereby the operation is focused primarily on keyboard actions, while the mouse options are severely limited. Thanks to extensions there are many graphic interfaces available. The editor is controlled by entering commands in the configuration file .vimrc.
Vim is an editor that has several modes. Depending on which mode is currently active, the characters you enter are interpreted in different ways. This structure differentiates it from many other Linux text editors, which could prove tricky for inexperienced users, but on the other hand, allows advanced users to work quickly and effectively. The following table explains the basic modes:
Mode | Description |
---|---|
normal mode | This is the mode that Vim will usually start in. You can navigate and manipulate text. |
insert mode | You can edit texts directly and insert new text. Only a few keys or combinations have a specific function so it depends if your keyboard has enough meta keys (e.g. Ctrl, Alt, etc.). |
visual mode | With this mode, you can perform most normal commands and sometimes extra ones on certain texts. It’s also possible to navigate and manipulate text selections. |
select mode | This is similar to visual, but its behavior is more like MS Windows. With this mode, you can replace selected text with newly-entered text. |
command-line | This is the mode used to entering editor commands such as '!', '/', and '?'. After the command has been carried out, Vim automatically reverts to standard mode. |
ex-mode | This mode is similar to the command-line mode, but is optimized for batch processing. |
Features of the Vim text editor
Vim outdoes many other text editors thanks to its extensive range of functions. The open source editor offers an abundance of extensions and configuration options in particular. The tools are very simple to use even if they may initially not be that intuitive due to the program’s complexity. To counteract this, Vim has a number of useful aids such as various search functions and extensive online documentation [Vim the docs – tips for using the text editor] (http://vimdoc.sourceforge.net/) as well as Vim tutorials and FAQs. Thanks to the syntax highlighting for more than 500 languages and file types, you can review the respective text file quickly and easily. In addition, there are various modifications such as the graphical user interfaces, mentioned above, which increase usability. Worth mentioning is gVim that has extra graphically prepared menu items and toolbars as well as the extension 'Cream' which enables the most important commands to be executed using the mouse.
An overview of Vim editor’s additional features:
- Spell check: if set spell command is activated, dictionaries for each language can be downloaded and expanded according to your needs.
- Autocomplete: can be used in insert mode with the key combinations [Ctrl] + [n] or [Ctrl] + [p].
- Tabs: different files or even the same file can be accessed in different tabs with different display windows.
- Unlimited undo and redo function: changes can be undone or redone indefinitely, even when Vim has been shut down in the meantime.
- Extensive runtime files: contain various rules for syntax and indentation marks, color palettes, standard extensions, etc.
- Own scripting language: the text editor can easily be expanded using the scripting language, Vimscript.
- Macros: to run scripts or commands in one simple step, macros can be logged and executed.
- Encryption: Vim files can be encrypted using the Blowfish algorithm.
- Folding: texts or excerpts that belong together can be folded in order to increase the clarity.
How to install the editor
As already mentioned, Vim is available for different platforms. On the official website, you can find download files for Linux/Unix, Windows, Amiga, and all kinds of Mac OS systems as well as in different versions along with installation tips. If you want to install Vim on a Windows PC, you have two options:
- Download the current, self-installing .exe file from the PC directory and start the installation by double-clicking.
- You can opt for one of three user interfaces offered in the same directory – vim74.zip, gvim74ole.zip or gvim73_46_s.zip – and download them. You also need the runtime file vim74rt.zip, which can also be found in the directory. Once you’ve downloaded both .zip files, unzip them in a common directory on your PC.
The installation file for Linux distributions is included in most package managers. You can install Vim using this command:
sudo apt-get install vim
You can download the source files too – for example, in the GitHub directory of the text editor so you can be sure you’re installing the newest version, or when you’re planning to make changes to the source code.
What differentiates Vim from other editors
The main features of Vim that separate it from other text editors are the various editing modes, the crucial role of keyboard shortcuts, and the practically unlimited amount of functions. The text editor has a lack of user-friendliness to thank for its dubious reputation. Despite its impressive range of features, its usability lets it down and may indeed take some getting used to. Comparable Windows and Linux editors like the equivalent Emacs and the Nano, Sublime Text, and Textadept aren’t built in a modular way and are therefore more intuitive for inexperienced users. You definitely won’t feel alone when you start using this text editor: thanks to the widely dispersed community that has emerged over the past decade the open source tool is growing, as is the number of extensions you can find, for example on VimAwesome. There are also several online manuals, forums, wikis, as well as tutorials that provide assistance and troubleshooting and are operated by members of the community. A particularly original and recommendable option is the online learning game Vim Adventures, where you can learn Vim in a playful way.