Vim

format_list_bulleted Contenido keyboard_arrow_down
ImprimirCitar

Vim (from Vi IMproved) is an enhanced version of the Vi text editor, present on all UNIX systems.

Its author, Bram Moolenaar, presented the first version in 1991, since which date it has undergone many improvements. The main feature of both Vim and Vi is that they have different modes to switch between to perform certain operations, which makes them different from most common editors, which have only one mode where commands are entered using key combinations or graphical interfaces.

Vi IMproved

Vim, like its predecessor Vi, is used from a Terminal in text mode. It is controlled entirely by keyboard. This is partly because Vi was developed in the mid-1970s, when terminals communicated with a host computer over a serial connection, which was not very fast (20Kbps). The limitations of the terminals of the time gave rise to the concept of different modes, an idea that has proved very profitable ever since. Vim is almost 100% compatible with Vi, although it has many improvements and even has versions with a graphical interface and menus that can be operated by the mouse (gvim or kvim), as well as a simplified version, evim that behaves like a editor without different modes.

Vim is available for many operating systems and can be found on almost any GNU/Linux system and on all *BSD systems, where it can often be run via the vi, which invokes Vim via a symbolic link or alias. When vim starts, it starts in command mode, and displays the version on the screen.

Evolution of Vim

Figure 1: Capture of gVim, one of the implementations Vim, editing this same article and emacs simultaneously in two different windows.

When Bram Moolenar bought an Amiga computer in the late 1980s, he wanted to continue using the Unix editor he had become accustomed to, but the Vi clones available for the Amiga did not suit him. So in 1988 he took the Vi clone Stevie 1.0 as the basis to start developing Vim. At first he called it Vi IMitation (imitation of Vi), since at first his main objective was to emulate the functionalities that Vi had in his new system. In 1991 version 1.14 appeared on the "Fred Fish disk #591", a collection of free software for the Amiga. Version 1.22 was the first to appear with versions for Unix and MS-DOS. By those times the acronym that gave it its name had already changed to Vi IMproved.

Figure 2: Vim with the following characteristics: Number of lines, Unicode, syntax highlighting and folding text.

In the following years Vim underwent great improvements. An important step was taken by incorporating windows in version 3.0 (1994) (Figure 1). With Vi you can have several files open in the same session, but you can only see one at a time; Vim windows allow you to view them simultaneously. Since version 4.0 (1996) a graphical user interface (GUI) has been available, which was started by Robert Webb. Since version 5.0 (1998) Vim has syntax highlighting (Figure 2).

Figure 3: New Vim 7 features: orthographic correction and automatic text completion.

Main features

  • Integrated orthographic correction
  • Automatic Text Completer
  • Tab navigation
  • Multiple windows, which divide the editing area horizontally or vertically.
  • Summary of syntax dependent on programming language or used labels
  • Orders to undo and redo
  • Understanding more than 200 different syntax
  • Scripting Language for Programming Extensions
  • Completed orders, words and file names
  • Compression and decompression of files, which allows editing compressed files
  • Recognition of file formats and conversion between them.
  • History of orders executed
  • Recording and reproduction of macros
  • Saved from intersessional configuration
  • Automatic and manual code
  • Optional graphic interface
  • Highly configurable and customizable
  • Almost 100% compatible with vi, but without many of its flaws

Vim Help

Vim has excellent documentation, which abides by the maxim An undocumented feature is a useless feature. The documentation, in text format, is very comprehensive and easy to understand. Through a search, the user accesses the description of various functionalities that can solve their problem. Through Vim's own syntax highlighting, keywords are highlighted (Figure 3).

By key combinations executed when the cursor is over a keyword you can navigate through the help, going back if necessary. In the graphical version you can also use the mouse for this purpose. The :helpgrep command is important, as it allows the user to search for a word in the help text, without it being necessary for it to be a keyword (Figure 4). The help is completed by an HTML version available for consultation on the Internet and an extensive list of frequently asked questions (FAQ).

Advantages for programmers

Vim is highly customizable and extensible, which makes it very attractive to users who demand a great deal of control and flexibility in text editing. Text input is made easier with a number of features designed to increase the efficiency of the keyboard. Users can execute complex commands such as key mapping, which can be customized and extended. The recording feature allows the creation of macros to automate keystroke sequences and call internal or user-defined functions. "Abbreviations", similar to macros and mappings, make it easy to expand from short to long text strings and can also be used to correct errors. Vim also has an easy mode for users looking for a simple editor. There are many extensions (plugins) available that add or extend functionality such as syntax and semantic error checking, Git integration, display colors in CSS. These complex scripts are usually written in the internal language "vimscript" (also known as VimL), but they can also be written in other languages.

Vim is an editor made by programmers for programmers. To make programming easier, Vim has an "edit, compile, fix" mode. In the same way as integrated development environments, you can edit the source code as well as call an external compiler, and interpret its results. If there are compile errors, they are displayed in a window. The error messages direct the user to the area in which they have been found in order to correct them. Then the "edit, compile, correct" and, if necessary, correct new errors. The programmer's job is also made easier by syntax highlighting and code folding functionality (see ':help quickfix').

File Comparison

Comparing two (or more) versions of a file is a frequent task for some users. Vim offers a simple solution, the two different versions of the file are displayed in two contiguous windows with the differences highlighted (Figure 5). In this way, the differences inserted in the versions can be seen colored. For example, deletions appear in red and new insertions in purple.

There are commands that allow you to place the cursor on the next and previous differences ([c and ]c), in addition to dumping these differences to the other file (do and dp).

The interpreted language of Vim

Vim has an interpreted language, or scripting, for programming new features, through which particular operations too complex to be performed with a macro can be automated. Scripts can be read and interpreted using the :source command.

The language is called vimscript or VimL)

Vim macros can contain a script in the normal way, but they can also call external commands or functions written in vimscript for more complex tasks. Almost all of Vim's core function extensions (plugins) are written in vimscript, but they can also use other languages such as Perl, Python, Lua, Ruby, Tcl, or Racket.

These extensions can be installed manually or by using an extension manager such as Vundle, Pathogen, or Vim-Plug.

Vimscript files are saved as plain text, similar to any other code, and the extension is usually .vim. An exception to this is the Vim configuration file which has the extension .vimrc.

Example

" This is the Hello World program in Vim script.I "Hello, world!"" This is a simple while loop in Vim script.Let's go. i=1while i . 5I "count is" i Let's go. i +=1endalet i

Modes

Vim is a modal editor, which means that you can work in different modes to accomplish a given task. To see what mode Vim is in, you must have the showmode option enabled. Vim's six modes are described below. The first three are the modes of the original vi. The five additional modes are not to be understood separately, but rather in combination with the base mode. See also the Vim help on this: ':help vim-modes'.

Command mode

Vim starts in command mode, also known as normal mode. In this mode you can use key combinations to, for example, copy lines and work on text formatting. This is the core mode, from which you switch to the other modes. If you don't know what you're doing, double-pressing the Escape key can always return to normal mode. If you were already in normal mode and both the Vim and terminal settings allow it, Vim beeps.

Insert mode

In insertion mode when the keys are pressed the text is edited as in other editors. You can switch from command mode to insert mode by pressing the i key. There is a wide range of commands to go to insertion mode, which differ substantially, as they allow, for example, editing at the end of the line, at a specific point in the text, editing by deleting a word, among many others. An expert user can take a great advantage of the existence of this variety of orders.

In insert mode all keys have some function other than mere insert, which are activated by simultaneously pressing the Ctrl Key or Shift key. The Esc key is very important in insert mode, as it allows you to switch from insert mode to command mode.

Switching to command mode to perform certain tasks greatly increases editing efficiency, and you can take advantage of the full power of Vim.

Command line mode

Vim version 7.4.1689 running on GNU Linux Ubuntu 16.04

This mode is accessed by pressing the colon : key. After the colon you can enter complex commands, such as search and replace with regular expressions. By pressing the Esc key you can return to command mode. Searches can be performed with the command / (forward) and ? (backward). You can also filter lines using !.

Visual mode

This mode is an improvement over vi. By means of certain key combinations in combination with the cursor movement keys, a text area can be marked, be it a group of lines or a block. Once you have the marked text you can use command mode commands to manipulate it. The operations that can be performed in this mode are simpler than those in command mode.

Selection mode

This mode starts out like visual mode, in that you have to select a block of text. After selection, you can switch to selection mode by Control-G. Once in the mode, if a printable key is pressed, the selected text is deleted, the selection mode is terminated, and the symbol corresponding to the key pressed appears. The selection can be extended by pressing shift and the arrow keys, the usual behavior in Microsoft Windows programs. This mode can be ended by pressing the Escape key.

Ex Mode

This mode is similar to command line mode, with the difference that after executing an order it does not return to command mode. This mode is entered by pressing Q and ended with vi. In this mode Vim mimics the UNIX editor ex, which manipulated text line by line due to limitations at the time, rather than editing the entire page.

GVim

Capture of gVim, one of the implementations Vim, editing a Wikipedia article.

gVim is a graphical version of the Vim text editor. gVim works with the gtk libraries. It maintains the functionality of Vim, and adds menus and a graphical environment (it works outside of the console/terminal).

Their main advantage, for new users, dropdown menus involve a somewhat less harsh learning curve. Its main disadvantage is that it is not installed by default on all systems (for example, it is not on servers without a graphical environment).

Operating systems

A virtue of Vim is that it can be run on many operating systems. This is important for users, such as system administrators who must work on many different platforms. It can run on the following operating systems: AmigaOS, Atari MiNT, BeOS, DOS, GNU/Linux, Mac OS, NextStep, OS/2, OSF, RISC OS, IRIX, Unix (many varieties such as BSD, AIX and HP-UX), VMS, and Windows 3.x/95/98/ME/2000/NT/XP.

Pros and cons

Criticism

The criticisms apply to Vi and Vim alike, as they are based on the same concept and their modes of operation are completely different from most current conventional editors. Above all they concern the separation of operations into different modes and the need to learn numerous key combinations, without which it is not possible to work efficiently. Currently, the lack of use of the mouse as an extra complement to the key combinations is considered an anachronism, since it can lead to frustration for the occasional user. Only after prolonged learning is it possible to increase productivity.

Advantages

Desktop background with the Vim logo.

Most Vim users report that this editor increases their productivity compared to simpler editors once the learning curve has been overcome. Key combinations can be memorized using mnemonic methods, as they relate to words English. The intrinsic complexity of learning the instructions is rewarded by the improvement in efficiency. Expert users can, using a few key combinations, copy text, format it, or sort it in many different ways, which can only be done in most editors by considerably more complex operations. It takes a bit of experience to see that statement combinations that allow for complex text edits are made easy with Vim. On the other hand, the new versions allow the use of the mouse and incorporate graphic menus, which make it easier to work with Vim in a similar way to other editors. It is often installed as a base editor because of its small size and speed on resource-constrained UNIX-based platforms.

Awards

Vim was the winner of the Readers' Choice Awards from Linux Journal in the Favorite Text Editor category from 2001 to 2005 and won the Slashdot Bernie Award as the Best Open Source Text Editor as well as the 1999 Linuxworld Editors' Choice Award.

License

Vim is distributed under a Charityware license compatible with the GNU General Public License. and stands for GPL (General Public License). This means that Vim abides by the same terms, but encourages users to donate to orphaned children in Uganda through ICCF Holland.

Development and community

Vim is developed by Bram Moolenaar and many volunteers. The Vim help page for the current version lists more than 50 contributors. In addition there are a large number of people who have helped, not only in the development of the software, but also in porting it to other operating systems, testing new versions, reporting bugs, writing documentation and translating the help system. They also answer user questions, adapt Vim to other projects and many other things.

All users can contribute by making scripts or giving advice. There is a very active mailing list, useful for both new and experienced users, with quick and competent responses.

Influence on other programs

  • qutebrowser (Web browser that is operated by keyboard).
  • VNote (Application to take notes).
  • Kate (Has a mode to edit in mode VI)
  • vimium (Extension for Chrome to use VIM style shortcuts)
  • ranger (VIM-style file manager)
  • Geany (Has a VIM-type shortcut mode)
  • vit (TaskWarrior interface with VIM style accesses)
    Configuración de Kate para usarlo como Vi/VIM

Differences with the Vi editor

Vim adds very important features compared to the old Vi editor, some of these improvements are:

  • The possibility of undoing multiple times consecutively.
  • It allows you to work with more than one window and file at a time.
  • The keyboard arrows can be used during the Insertion mode.
  • It is capable of recording commands (macros).
  • The visual mode allows you to select text easily and powerfully.
  • You can work conveniently with text locked between quotes, parentheses, html brands, etc.
  • Integrated support system.
  • Command history.
  • Command expansion.
  • Horizontal displacement

Easter Egg

Easter Egg in the text editor Vim.

The Vim text editor contains at least one Easter egg as a tribute to writer Douglas Adams' Hitchhiker's Guide to the Galaxy. The command :help 42 produces the text:

«What is the meaning of life, the universe and everything ? 42. Douglas Adams, the only person who knew what this question really was about is now dead, unfortunately. So now you might wonder what the meaning of death is...»

What is the meaning of life, the universe and all? 42. Douglas Adams, the only person who knew what this question was about, is now dead, unfortunately. So now you might wonder what the meaning of death is...»)

Contenido relacionado

Ada (programming language)

Ada is a statically typed, strongly-typed, object-oriented programming language that was designed by Jean Ichbiah of CII Honeywell Bull on behalf of the US...

Device Filesystem

Device Filesystem is a virtual file system, used by the Unix operating system and operating systems derived from it, whose purpose is to control device files....

Algorithm

In mathematics, logic, computer science, and related disciplines, an algorithm is a set of defined and unambiguous, ordered and finite instructions or rules...
Más resultados...
Tamaño del texto:
undoredo
format_boldformat_italicformat_underlinedstrikethrough_ssuperscriptsubscriptlink
save