Differences between VI and VIM

Source: Internet
Author: User

From; http://blog.csdn.net/carolzhang8406/article/details/6117593

From Wikipedia http://zh.wikipedia.org/wiki/Vim.

Vim is a text editor developed from VI. Code Completion, compilation, error jump, and other convenient programming functions are particularly rich and widely used by programmers. It is used in parallel with Emacs to become your favorite editor for Unix-like systems.

The first version of VIM was released by Bram moolenaar in 1991. The original name is VI imitation. With the increasing number of functions, the official name is changed to VI improved. Free Software is now released in open source code mode.

Vim history

Bram moolenaar purchased his
There is no commonly used editor VI on the Amiga computer. Bram started to copy Stevie from an open-source VI and developed Vim 1.0. The initial goal was to completely copy the VI function. At that time, VIM was short for VI imitation (simulation. In 1991, VIM 1.14 was included in the "Fred fish disk #591" Free Software set for amiga. 1992 version 1.22
Vim is transplanted to Unix and
On the MS-DOS. From that time on, the full name of VIM was changed to VI improved (improved.

Afterwards, VIM has added countless new features. As the first milestone, version 1994 added the multi-window editing mode (split windows) in 3.0 ). From then on, there can be more than one Vim editing file displayed on the same screen. Vim 1996, released in 4.0, is the first version that utilizes graphic interfaces (GUI. In April 5.0, VIM added the highlight (syntax highlighting) function. 2001
In Vim 6.0, code folding, plug-ins, multi-language support, Vertical Split windows, and other functions are added. The Vim version May 2006 released in 7.0 includes new functions such as spell check, context-related completion, and Tab editing. The latest version was released on July 15, August 2008.
Vim 7.2, which combines all the correction patches since Vim 7.1 and adds support for script floating point numbers.

Learning Curve

For most users, VIM has a steep
Learning curve. This means that the learning may slow down, but after some basic operations are mastered, the editing efficiency can be greatly improved. To help you learn, VIM provides Vim teaching for beginners. Generally, you can enter "vimtutor" in the Unix Command Line or click
On the Windows system desktop, enter the vim teaching icon. The Vim user manual details the basic and advanced functions of vim. Enter ": help user-Manual" in VIM to enter the user manual. In addition to the original English version, the manual was also translated into Chinese by volunteers.

New users should also learn the Vim Help system. You can enter "help" without parameters in VIM to read the Main Help file.

Mode

SlaveVIThe derived Vim has multiple modes. This unique design can easily confuse beginners. Almost all editors have two modes: insert and execute commands. Most Editors Use a different method than VIM: Command menu (mouse or keyboard driver ), the combination key (usually composed of the control key (CTRL) and ALT key (ALT) or the mouse input. Like VI, VIM only switches between these modes through the keyboard. This allows Vim to minimize the combination of keys without having to perform menu or mouse operations. The speed and efficiency can be greatly improved for text reporters or programmers.

Vim has 6 basic modes and 5 derived modes.

1. Basic Mode

(1) Normal Mode

In normal mode, you can execute General Editor commands, such as moving the cursor and deleting text. This is also the default mode after Vim is started. This is exactly the opposite of the operation method expected by many new users (most Editors Use the insert mode by default ).

Most of Vim's powerful editing capabilities come from common mode commands. Common Mode commands often require the end of an operator. For example, the normal mode command "DD" deletes the current line, but the first "D" can be followed by another mobile command to replace the second "D ", for example, you can use the "J" key to move to the next row to delete the current row and the next row. In addition, you can also specify the number of command repetitions, "2dd" (repeated "DD" twice), the effect is the same as that of "DJ. The user has learned a variety of commands for moving/redirecting between texts and other editing commands in common mode, and can flexibly combine and use them, text editing is more efficient than those with no mode.

In normal mode, there are many ways to enter the insert mode. Generally, press the "a" (append/append) or "I" (insert/insert) Key.

(2) Insert Mode

In this mode, most keys insert text to the text buffer. Most new users want to maintain this mode throughout the text editor editing process.

In insert mode, you can press ESC to return to normal mode.

(3) visual mode

This mode is similar to the normal mode. However, the move command expands the highlighted text area. The highlighted area can be a character, line, or text. When executing a non-mobile command, the command will be executed to the highlighted area. Vim's "Text object" can also be used in this mode like mobile commands.

(4) Select Mode

This mode is similar to the mode Editor (in Windows standard text control mode ). In this mode, you can use the mouse or cursor key to highlight and select text. However, if you enter any character, VIM will replace the selected highlighted text block with this character and automatically enter the insertion mode.

(5) Command Line Mode

In command line mode, you can enter the text that will be interpreted and executed. For example, execute the command (":" key), search ("/" and "? "Key) or filter command ("! "Key ). After the command is executed, VIM returns to the mode before the command line mode, which is usually the normal mode.

(6) ex Mode

This is similar to the command line mode. Multiple commands can be executed at a time before the ": Visual" command leaves the ex mode.

2. derived Mode

(1) operator wait Mode

In normal mode, VIM waits for an "action" to complete an operation command. Vim also supports the use of "Text object" as an action in the operator wait mode, including "aw", a word (a word), and "as" sentence (a sentence) "AP" section (a paragraph) and so on.

For example, in normal mode, "d2as" deletes the current and next sentences. In visual mode, Apu capital all the letters in the current paragraph.

(2) Insert Normal Mode

In this mode, press Ctrl-o in insert mode. Now enter normal mode. After executing a command, VIM returns the insert mode.

(3) Insert visual mode

In this mode, press Ctrl-o in insert mode and start a visual selection. When you select cancel in the visible area, VIM returns the insert mode.

(4) Insert selection mode

Generally, this mode is entered by dragging the mouse in the insert mode or using the shift arrow key. When the selected region is canceled, VIM returns the insert mode.

(5) Replacement Mode

This is a special insert mode. In this mode, you can perform the same operations as the insert mode, but each input character overwrites the existing characters in the text buffer. In normal mode, press "R.

Others

Evim

Evim is a special GUI mode used to try its best to behave the same way as the "no mode" editor. The Editor automatically enters and stays in the insert mode. You can operate the text only by using the menu, mouse, and keyboard control keys. You can enter "evim" or "vim-y" in the command line. In
In Windows, you can also click the evim icon on the desktop.

Function

Summary

 

  • It can be fully compatible with the original VI According to Settings
  • Multi-buffer editing
  • Split windows of any number (horizontal or vertical)
  • Script Language with list and dictionary Functions
  • You can call Perl, Ruby, Python, TCL, and mzscheme in a script.
  • Abbreviations
  • Dynamic word completion
  • Multiple Undo and redo operations
  • Syntaxes highlighted for more than 400 text files
  • C/C ++, Perl, Java, Ruby, Python
    And more than 40 languages
  • Jump using the ctags label
  • File recovery after crash
  • Save and restore the cursor position and open buffer status (Session function)
  • Two files can be differentiated and the diff mode of the synchronization function can be implemented.
  • Remote File editing
  • Omni completion (context-related completion)

Help

Vim provides a large number of documents in the text format. Besides, VIM provides a variety of functions to quickly find a solution to the problem. According to Vim's Help File Syntax, keywords are highlighted in various colors. You can use the shortcut key to browse the Help file as in your browser. You can also move the cursor in the Help File in VIM of GUI. There are more than these functions to help users find a solution. The most important of them is
': Helpgrep' command. With this command, you can search for the desired content in all the help files, and use ': cwindows' to indicate the search result in another window, the search results are automatically redirected to the Help file. With the help of VIM, you can continue searching in the search results.

Functions related to program development

Vim is an editor developed by programmers to facilitate programming. Vim has various functions that make code writing easier and more enjoyable. Like the integrated development environment, VIM
It can be configured to compile the source code directly after editing the source code. If a compilation error occurs, an error is displayed in another window. Based on the error message, you can directly jump to the error location of the source file being edited. Code highlighting, text folding, and context join completion are all very helpful functions for programmers (refer
': Help quickfix ')

File comparison

You can compare text files line by line. Vim can display two versions of files side by side, and represent different parts in a variety of colors. The lines that have been changed, added, or deleted are highlighted in color. The lines that have not been changed are automatically collapsed.

For the two buffers opened in Vim, the content of the two buffers will be compared after diffthis is used respectively. The buffer to be compared can be a buffer in the memory that has not been stored in the disk.

When comparing the differences between the two files, you can use the: diffget and: diffput commands to perform bidirectional synchronization for each different file, or you can perform other edits on the content while the comparison is not at the same time, then compare the latest content with diffupdate.

When browsing the differences between the two files, you can use the commands in [C and] C normal mode to directly jump to the previous and next differences.

You can use options such as diffopt to more precisely control which differences are considered to be true differences. For example, you can set a comparison to ignore the differences in the number of blank characters.

In UNIX, you can use the vimdiff command.

Script Language

Vim has its own scripting language. Macros written in the scripting language can automatically perform complex operations. Use the-s option to start vim, or directly switch to the macro directory.
Run the ': source' command to execute the vim script. The Vim configuration file can be used as an example of the vim script. in UNIX and Linux, the configuration file name is. vimrc, and in windows, the configuration file is usually called _ vimrc. This file is being started
Vim is automatically executed. Vim
The script language can use Vim
For all commands in command line mode, the ': normal' command can also be used for all commands in normal mode. The Vim script language contains numbers and strings. A number represents a boolean type, 0 represents a false value, and a number other than 0 represents a true value. Latest
Vim 7 provides advanced data structures such as lists and associated arrays. Vim script language also has various comparison operators and arithmetic operators. The control structure implements
If branch and for/while loop. You can also define functions by yourself and use more than 100 types of predefined functions. The compiled script file can be debugged in the debugging mode.

Weaknesses

 

  • Reading large files is slow (vim.org can be used to download a script named largefile and install it with optimizations) largefile
  • Even if the file is not large, processing will slow down if there are very long lines (same as above)
  • Vim's script language is too complex. There is no command for Automatic Execution and window management. (New users often feel this way)
  • Keys like Ctrl-1 that cannot be mapped (limited to the performance of some character terminals)
Conversion from others' blogs: they are all multi-mode editors. The difference is that Vim is an upgraded version of vi. It is not only compatible with all instructions of VI, but also has some new features in it.
Vim has the following advantages: 1. Multilevel Revocation
We know that in VI, you can only undo the last command by pressing U, but you can undo it without limit in vim. 2. ease of use
Vi can only run in UNIX, while Vim can not only run on UNIX, windows, Mac, and other multi-operating platforms. 3. Highlight the syntax
Vim can use different colors to highlight your code. 4. Visualized operations
That is to say, VIM can run not only on the terminal, but also on X Window, Mac OS, and windows. 5. fully compatible with vi
In some cases, you can use Vim as VI.

From Wikipedia http://zh.wikipedia.org/wiki/Vim.

Vim is a text editor developed from VI. Code Completion, compilation, error jump, and other convenient programming functions are particularly rich and widely used by programmers. It is used in parallel with Emacs to become your favorite editor for Unix-like systems.

The first version of VIM was released by Bram moolenaar in 1991. The original name is VI imitation. With the increasing number of functions, the official name is changed to VI improved. Free Software is now released in open source code mode.

Vim history

Bram moolenaar purchased his
There is no commonly used editor VI on the Amiga computer. Bram started to copy Stevie from an open-source VI and developed Vim 1.0. The initial goal was to completely copy the VI function. At that time, VIM was short for VI imitation (simulation. In 1991, VIM 1.14 was included in the "Fred fish disk #591" Free Software set for amiga. 1992 version 1.22
Vim is transplanted to Unix and
On the MS-DOS. From that time on, the full name of VIM was changed to VI improved (improved.

Afterwards, VIM has added countless new features. As the first milestone, version 1994 added the multi-window editing mode (split windows) in 3.0 ). From then on, there can be more than one Vim editing file displayed on the same screen. Vim 1996, released in 4.0, is the first version that utilizes graphic interfaces (GUI. In April 5.0, VIM added the highlight (syntax highlighting) function. 2001
In Vim 6.0, code folding, plug-ins, multi-language support, Vertical Split windows, and other functions are added. The Vim version May 2006 released in 7.0 includes new functions such as spell check, context-related completion, and Tab editing. The latest version was released on July 15, August 2008.
Vim 7.2, which combines all the correction patches since Vim 7.1 and adds support for script floating point numbers.

Learning Curve

For most users, VIM has a steep
Learning curve. This means that the learning may slow down, but after some basic operations are mastered, the editing efficiency can be greatly improved. To help you learn, VIM provides Vim teaching for beginners. Generally, you can enter "vimtutor" in the Unix Command Line or click
On the Windows system desktop, enter the vim teaching icon. The Vim user manual details the basic and advanced functions of vim. Enter ": help user-Manual" in VIM to enter the user manual. In addition to the original English version, the manual was also translated into Chinese by volunteers.

New users should also learn the Vim Help system. You can enter "help" without parameters in VIM to read the Main Help file.

Mode

SlaveVIThe derived Vim has multiple modes. This unique design can easily confuse beginners. Almost all editors have two modes: insert and execute commands. Most Editors Use a different method than VIM: Command menu (mouse or keyboard driver ), the combination key (usually composed of the control key (CTRL) and ALT key (ALT) or the mouse input. Like VI, VIM only switches between these modes through the keyboard. This allows Vim to minimize the combination of keys without having to perform menu or mouse operations. The speed and efficiency can be greatly improved for text reporters or programmers.

Vim has 6 basic modes and 5 derived modes.

1. Basic Mode

(1) Normal Mode

In normal mode, you can execute General Editor commands, such as moving the cursor and deleting text. This is also the default mode after Vim is started. This is exactly the opposite of the operation method expected by many new users (most Editors Use the insert mode by default ).

Most of Vim's powerful editing capabilities come from common mode commands. Common Mode commands often require the end of an operator. For example, the normal mode command "DD" deletes the current line, but the first "D" can be followed by another mobile command to replace the second "D ", for example, you can use the "J" key to move to the next row to delete the current row and the next row. In addition, you can also specify the number of command repetitions, "2dd" (repeated "DD" twice), the effect is the same as that of "DJ. The user has learned a variety of commands for moving/redirecting between texts and other editing commands in common mode, and can flexibly combine and use them, text editing is more efficient than those with no mode.

In normal mode, there are many ways to enter the insert mode. Generally, press the "a" (append/append) or "I" (insert/insert) Key.

(2) Insert Mode

In this mode, most keys insert text to the text buffer. Most new users want to maintain this mode throughout the text editor editing process.

In insert mode, you can press ESC to return to normal mode.

(3) visual mode

This mode is similar to the normal mode. However, the move command expands the highlighted text area. The highlighted area can be a character, line, or text. When executing a non-mobile command, the command will be executed to the highlighted area. Vim's "Text object" can also be used in this mode like mobile commands.

(4) Select Mode

This mode is similar to the mode Editor (in Windows standard text control mode ). In this mode, you can use the mouse or cursor key to highlight and select text. However, if you enter any character, VIM will replace the selected highlighted text block with this character and automatically enter the insertion mode.

(5) Command Line Mode

In command line mode, you can enter the text that will be interpreted and executed. For example, execute the command (":" key), search ("/" and "? "Key) or filter command ("! "Key ). After the command is executed, VIM returns to the mode before the command line mode, which is usually the normal mode.

(6) ex Mode

This is similar to the command line mode. Multiple commands can be executed at a time before the ": Visual" command leaves the ex mode.

2. derived Mode

(1) operator wait Mode

In normal mode, VIM waits for an "action" to complete an operation command. Vim also supports the use of "Text object" as an action in the operator wait mode, including "aw", a word (a word), and "as" sentence (a sentence) "AP" section (a paragraph) and so on.

For example, in normal mode, "d2as" deletes the current and next sentences. In visual mode, Apu capital all the letters in the current paragraph.

(2) Insert Normal Mode

In this mode, press Ctrl-o in insert mode. Now enter normal mode. After executing a command, VIM returns the insert mode.

(3) Insert visual mode

In this mode, press Ctrl-o in insert mode and start a visual selection. When you select cancel in the visible area, VIM returns the insert mode.

(4) Insert selection mode

Generally, this mode is entered by dragging the mouse in the insert mode or using the shift arrow key. When the selected region is canceled, VIM returns the insert mode.

(5) Replacement Mode

This is a special insert mode. In this mode, you can perform the same operations as the insert mode, but each input character overwrites the existing characters in the text buffer. In normal mode, press "R.

Others

Evim

Evim is a special GUI mode used to try its best to behave the same way as the "no mode" editor. The Editor automatically enters and stays in the insert mode. You can operate the text only by using the menu, mouse, and keyboard control keys. You can enter "evim" or "vim-y" in the command line. In
In Windows, you can also click the evim icon on the desktop.

Function

Summary

 

  • It can be fully compatible with the original VI According to Settings
  • Multi-buffer editing
  • Split windows of any number (horizontal or vertical)
  • Script Language with list and dictionary Functions
  • You can call Perl, Ruby, Python, TCL, and mzscheme in a script.
  • Abbreviations
  • Dynamic word completion
  • Multiple Undo and redo operations
  • Syntaxes highlighted for more than 400 text files
  • C/C ++, Perl, Java, Ruby, Python
    And more than 40 languages
  • Jump using the ctags label
  • File recovery after crash
  • Save and restore the cursor position and open buffer status (Session function)
  • Two files can be differentiated and the diff mode of the synchronization function can be implemented.
  • Remote File editing
  • Omni completion (context-related completion)

Help

Vim provides a large number of documents in the text format. Besides, VIM provides a variety of functions to quickly find a solution to the problem. According to Vim's Help File Syntax, keywords are highlighted in various colors. You can use the shortcut key to browse the Help file as in your browser. You can also move the cursor in the Help File in VIM of GUI. There are more than these functions to help users find a solution. The most important of them is
': Helpgrep' command. With this command, you can search for the desired content in all the help files, and use ': cwindows' to indicate the search result in another window, the search results are automatically redirected to the Help file. With the help of VIM, you can continue searching in the search results.

Functions related to program development

Vim is an editor developed by programmers to facilitate programming. Vim has various functions that make code writing easier and more enjoyable. Like the integrated development environment, VIM
It can be configured to compile the source code directly after editing the source code. If a compilation error occurs, an error is displayed in another window. Based on the error message, you can directly jump to the error location of the source file being edited. Code highlighting, text folding, and context join completion are all very helpful functions for programmers (refer
': Help quickfix ')

File comparison

You can compare text files line by line. Vim can display two versions of files side by side, and represent different parts in a variety of colors. The lines that have been changed, added, or deleted are highlighted in color. The lines that have not been changed are automatically collapsed.

For the two buffers opened in Vim, the content of the two buffers will be compared after diffthis is used respectively. The buffer to be compared can be a buffer in the memory that has not been stored in the disk.

When comparing the differences between the two files, you can use the: diffget and: diffput commands to perform bidirectional synchronization for each different file, or you can perform other edits on the content while the comparison is not at the same time, then compare the latest content with diffupdate.

When browsing the differences between the two files, you can use the commands in [C and] C normal mode to directly jump to the previous and next differences.

You can use options such as diffopt to more precisely control which differences are considered to be true differences. For example, you can set a comparison to ignore the differences in the number of blank characters.

In UNIX, you can use the vimdiff command.

Script Language

Vim has its own scripting language. Macros written in the scripting language can automatically perform complex operations. Use the-s option to start vim, or directly switch to the macro directory.
Run the ': source' command to execute the vim script. The Vim configuration file can be used as an example of the vim script. in UNIX and Linux, the configuration file name is. vimrc, and in windows, the configuration file is usually called _ vimrc. This file is being started
Vim is automatically executed. Vim
The script language can use Vim
For all commands in command line mode, the ': normal' command can also be used for all commands in normal mode. The Vim script language contains numbers and strings. A number represents a boolean type, 0 represents a false value, and a number other than 0 represents a true value. Latest
Vim 7 provides advanced data structures such as lists and associated arrays. Vim script language also has various comparison operators and arithmetic operators. The control structure implements
If branch and for/while loop. You can also define functions by yourself and use more than 100 types of predefined functions. The compiled script file can be debugged in the debugging mode.

Weaknesses

 

  • Reading large files is slow (vim.org can be used to download a script named largefile and install it with optimizations) largefile
  • Even if the file is not large, processing will slow down if there are very long lines (same as above)
  • Vim's script language is too complex. There is no command for Automatic Execution and window management. (New users often feel this way)
  • Keys like Ctrl-1 that cannot be mapped (limited to the performance of some character terminals)
Conversion from others' blogs: they are all multi-mode editors. The difference is that Vim is an upgraded version of vi. It is not only compatible with all instructions of VI, but also has some new features in it.
Vim has the following advantages: 1. Multilevel Revocation
We know that in VI, you can only undo the last command by pressing U, but you can undo it without limit in vim. 2. ease of use
Vi can only run in UNIX, while Vim can not only run on UNIX, windows, Mac, and other multi-operating platforms. 3. Highlight the syntax
Vim can use different colors to highlight your code. 4. Visualized operations
That is to say, VIM can run not only on the terminal, but also on X Window, Mac OS, and windows. 5. fully compatible with vi
In some cases, you can use Vim as VI.
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.