Vim is a text editor developed from VI. Code completion, compilation and error jumps and other convenient programming features are particularly rich, in the programmer is widely used. And Emacs are a favorite editor for Unix-like system users.
The first version of Vim was released by Bram Moolenaar in 1991. The initial abbreviation is VI imitation, with the continuous increase of function, the official name changed to VI improved. It is now free software released in open source mode.
Vim history
Bram Moolenaar in the late 80 when he purchased his Amiga computer, the Amiga had not had his most commonly used editor VI. Bram started with an open source VI replication Stevie, and developed the 1.0 version of Vim. The original goal is to completely replicate the function of VI, at that time Vim is the VI imitation (analog) abbreviation. The 1991 Vim 1.14 Edition was included in the free software set by the Amiga "Fred Fish Disk #591". The 1992 1.22 version of Vim was ported to UNIX and MS-DOS. From that time on, the full name of Vim became Vi improved (improved).
After that, Vim has added countless new features. As a first milestone, the 3.0 version of 1994 added the multi-window editing mode (split window). The number of Vim editing files that can be displayed on the same screen after that can be more than one. The 1996 release of Vim 4.0 was the first version to utilize a graphic interface (GUI). 1998 5.0 version of Vim added the highlight (syntax highlighting) feature. The 2001 version of Vim 6.0 added features such as code folding, plugins, multi-language support, vertical split windows, and more. The May 2006 release of Vim 7.0 has added new features such as spell checking, context-sensitive completion, and tab editing. The latest version is Vim 7.2, released in August 2008, which incorporates all of the remediation patches since VIM 7.1 and added the script's floating point support.
Learning curve
For most users, VIM has a steep learning curve. This means that it may be slow to start learning, but once you have mastered some basic operations, you can significantly improve your editing efficiency. To help with learning, Vim prepares the vim teaching for beginners. You can usually enter "Vimtutor" under the UNIX system command line or click the Vim instruction icon on the Windows system desktop. The basic and advanced features of Vim are described in more detail in the VIM user manual. You can enter ": Help User-manual" into the user manual in Vim. In addition to the original English version, the Handbook has also been translated into various languages by volunteers, including Chinese.
New users should also learn about Vim's help system. You can enter "Help" without parameters in vim to read the main helper file.
Mode
The vim derived from VI has a variety of modes, and this unique design makes it easy to confuse beginners. Almost all editors have two modes of inserting and executing commands, and most editors use a different approach to Vim: a command menu (mouse or keyboard driver), a combination of keys (usually with the control key (CTRL) and Alt (ALT)), or mouse input. Vim and VI, just as the keyboard to switch among these modes. This allows vim to operate without a menu or mouse, and to minimize the operation of key combinations. It can greatly enhance the speed and efficiency of the text entry clerk or programmer.
Vim has 6 basic modes and 5 derivation modes.
1. Basic mode
(1) Normal mode
In normal mode, users can perform general editor commands, such as moving the cursor, deleting text, and so on. This is also the default mode after Vim is started. This is exactly the opposite of what many new users expect (most editor default mode is insert mode).
A large part of Vim's powerful editing capabilities comes from its normal mode commands. Normal mode commands often require an operator end. For example, the normal mode command "DD" deletes the current row, but the first "D" can be followed by another move command instead of the second "D", such as the "J" Key moved to the next line to delete the current row and the next row. You can also specify the number of commands to repeat, "2DD" (repeat "DD" two times), and "DJ" effect is the same. Users learn a variety of text between the move/jump commands and other common mode of editing commands, and can be used flexibly combined, can be more efficient than those without the pattern of the editor for text editing.
In normal mode, there are many ways to get into insert mode. The more common way is to press "a" (append/append) key or "I" (insert/insert) key.
(2) Insert mode
In this mode, most keystrokes insert text into the text buffer. Most new users want this mode to persist throughout the text editor editing process.
In insert mode, you can press the ESC key back to normal mode.
(3) Visual mode
This pattern is similar to normal mode. However, the move command expands the highlighted text area. The highlighted area can be a character, a line, or a piece of text. When a non-moving command is executed, the command is executed to the highlighted area. Vim's "text object" can also be used in this mode as the move command.
(4) Select mode
This pattern is similar to the behavior of the modeless editor (the way Windows standard text controls are). In this mode, you can use the mouse or cursor keys to highlight the selection of text, but the input of any character, Vim will use this character to replace the selected highlighted text block, and automatically enter the insertion mode.
(5) Command line mode
In command-line mode, you can enter text that will be interpreted and executed. For example, execute the command (":" Key), Search ("/" and "?" keys) or filter the command ("!" key). After the command is executed, VIM returns to the pattern before the command-line mode, usually in normal mode.
(6) Ex mode
This is similar to command-line mode, where you can execute multiple commands at one time before using the ": visual" command to leave the ex mode.
2. Derivation mode
(1) Operator wait mode
This derivation pattern refers to normal mode, in which Vim waits for an "action" to complete this command after executing an action command. Vim also supports the use of "text object" as an action in the operator wait mode, including "AW" a word (word), "as" a sentence (a sentence), "AP" a paragraph (a paragraph), and so on.
For example, in normal mode "D2as" deletes the current and next sentence. In visual mode, "ApU" capitalizes all the letters in the current paragraph.
(2) inserting normal mode
This mode is entered when the Ctrl-o key is pressed in insert mode. This time temporarily into normal mode, after executing a command, VIM returns to insert mode
(3) Insert Visual mode
This mode starts when you press the Ctrl-o key in insert mode and start a visual selection. When you select Cancel in the viewable area, VIM returns to insert mode.
(4) Insert selection mode
This mode is usually accessed by dragging the mouse or by the shift arrow key in insert mode. When the selection area is canceled, VIM returns to insert mode.
(5) Replacement mode
This is a special insert mode in which the same operation can be done in the same mode as the insert mode, but each input character overrides the existing character in the text buffer. Press "R" key in normal mode to enter.
Other
Evim
Evim is a special GUI mode used to perform as much as possible with the "modeless" editor. The editor automatically enters and stays in insert mode, and the user can only manipulate the text with the menu, mouse, and keyboard control keys. You can enter "Evim" or "vim-y" at the command line. Under Windows, you can usually also click the Evim icon on your desktop.
Function
Profile
- Can be fully compatible with the original VI according to the setting
- Multi-buffered editing
- Any number of split windows (horizontal, vertical)
- scripting language with list and dictionary capabilities
- Perl, Ruby, Python, TCL, Mzscheme can be called in the script
- Word abbreviation function
- Dynamic Word Completion
- Multiple undo and Redo
- Syntax highlighting for more than 400 types of text files
- Automatic indentation of more than 40 languages, such as C + +, Perl, Java, Ruby, Python, etc.
- Use the Ctags tab to jump
- File recovery after crash
- Save restore of cursor position and open buffering State (Session function)
- Diff mode for two files with differential, synchronous function
- Remote file editing
- Omni Complement (context-dependent completion)
Help
Vim provides a large number of documents in the form of text. And Vim offers a wide variety of functions to quickly find solutions to problems. According to Vim's own Help file syntax, keywords are represented by a variety of striking colors. You can use shortcut keys to browse Help files as you would in a browser. You can also use the mouse to move through the Help file in the GUI version of Vim. There are more features to help users find problem solutions, the most important of which is ': Helpgrep ' command. With this command, the user can search all the help files for what they want to see, using ': Cwindows ' to represent the results of the search in another window, and automatically jump within the Help file based on the results of the search. With Vim's help function, you can continue searching in the results of your search.
program Development related functions
Vim is an editor developed by programmers for the convenience of writing programs. Vim has a wide variety of features that make writing code work easier and more enjoyable. Like the integrated development environment, VIM has functionality that can be configured to compile directly after the code source file is edited. In the case of a compilation error, an error can be displayed in another window. Depending on the error message, jump directly to the source file where you are editing the error. Code highlighting, text folding, contextual correlation completion are especially helpful for programmers (see ': Help Quickfix ')
File comparison
You can compare text files on a line-by-row basis. Vim can display two versions of the file side-by, while representing a different part in a variety of colors. Changed, added, or deleted rows are highlighted in color highlights, and the ones that have not changed are automatically folded.
For the two buffers already open in Vim, use: diffthis the contents of the two buffers will be compared, and the buffer being compared can be an in-memory buffer that has not yet been saved.
When comparing the differences of two files, you can use: Diffget and: Diffput command for each of the different two-way synchronization, you can also compare the content of other edits, and then use: Diffupdate to the latest content to re-compare.
When browsing the differences between the two files, you can jump directly to the previous and next differences with [C and]c two normal mode commands.
You can more finely control what differences are considered to be true differences through options such as diffopt, such as differences in the number of whitespace characters that can be ignored when you set comparisons.
This feature can be used with the Vimdiff command under Unix.
scripting language
Vim has her own scripting language, and macros written in scripting languages allow for complex operations to be performed automatically. Use the-S option to start vim, or simply switch to the same directory as the macro that uses the ': Source ' command to execute the vim script. Vim's configuration file can be used as an example of vim scripts, Unix and Linux under the configuration file name is. vimrc,windows profiles are generally called _VIMRC. This file is automatically executed when Vim is started. The VIM scripting language can use all the commands in the VIM command-line mode, and use the ': normal ' command to also use all the commands in the usual pattern. The Vim scripting language has two data types: numeric and string. The number represents the Boolean type, 0 is false, and the number outside represents true. The latest Vim 7 provides advanced data structures such as lists, associative arrays, and more. The Vim scripting language also has a variety of comparison operators and arithmetic operators. The control structure implements the if branch and the For/while loop. Users can also define their own functions, and can use more than 100 predefined functions. The script file that you write can be debugged in debug mode.
The shortcomings
- Large files are slow to read (use vim.org to download script named Largefile and install optimized) Largefile
- Even if the file is small, the processing will be slow if there are very long lines (IBID.)
- Vim's own scripting language is too complex. Lack of commands for automatic Execution and window management. (beginners tend to have this feeling)
- There are keys like Ctrl-1 that cannot be mapped (limited to the performance of certain character terminals)
Transfer from others blog: They are multi-mode editor, the difference is that Vim is the upgrade version of VI, it is not only compatible with all VI directives, but also some new features in it.
These advantages of VIM are mainly embodied in the following aspects: 1, Multilevel undo
We know in VI, press u can only undo the last command, and in Vim can be unlimited undo. 2. Ease of Use
VI can only run on Unix, and vim not only runs on Unix,windows, Mac and other multi-operating platforms. 3. Syntax highlighting
Vim can use different colors to highlight your code. 4. Visual operation
This means that VIM can be run not only at the terminal, but also in X window, Mac OS, Windows. 5. Fully compatible with VI
In some cases, you can use Vim as VI.
The difference between VI and VIM