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. Now it's free to release in open source mode.
First, let's take a look at the text
Content of the First VI edit
650) this.width=650; "title=" Gch]iv%pg7}fd5i3i@n[18c.png "src=" https://s1.51cto.com/wyfs02/M01/8E/E0/ Wkiom1joeuyr6swjaaaljm68vpy720.png-wh_500x0-wm_3-wmp_4-s_616080134.png "alt=" Wkiom1joeuyr6swjaaaljm68vpy720.png-wh_50 "/>,
The second one, let's look at the effects of vim.
650) this.width=650, "title=" $AISFD) a6h8k) wth@z{ue49.png "src=" https://s4.51cto.com/wyfs02/M01/8E/DE/ Wkiol1joezddy2nhaaar26esewo392.png-wh_500x0-wm_3-wmp_4-s_2392636581.png "alt=" Wkiol1joezddy2nhaaar26esewo392.png-wh_50 "/>
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
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
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 inside.
These advantages of vim are mainly reflected 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.
This article is from "Ah Kai" blog, please be sure to keep this source http://kaile.blog.51cto.com/12459560/1908111
The difference between VI and VIM