VI & VIM

Source: Internet
Author: User

why to use VI.

VI is a very unfriendly text editor, but why use it. Because: all Unix like systems will build a VI editor, and other text editors are not necessarily present; a lot of the editing interfaces of the software will call VI Vim's ability to edit the program, and it can be used to identify the correct character of the language, to facilitate programming; Because the program is simple, edit Editing speed is fast.

What is Vim .

You can view vim as the advanced version of VI, and VIM can display some special information in the form of a color or a bottom line. most of the current Distributions are in Vim Replace VI the function of the. If you use VI and then you see that the bottom right corner of the screen shows the number of the current RENGPUI, so your VI has been Vim replaced . For example, when you use Vim to edit a file in C programming language, or the shell script that we're going to be talking about, the vim is going to call the program's verbal sentence, depending on the file's associate name or the open information in the file, and the file's contents are automatically called. and display the code and general information in color.

VI the Use

Basically, vi is divided into three modes, such as "General Mode", "editor mode" and "command-order Mode". The role of these three modes is: General mode:

using VI to open a file directly into the general mode (this is the preset mode). In this pattern, you can use "up or down" keys to move the cursor , you can use "delete character" or "delete the whole line" to deal with the file, you can use "copy, paste" to deal with your files. You can delete, copy, paste, and so on in general mode, but you can't edit the contents of the file . Edit mode:

You can delete, copy, paste, and so on in general mode, but you can't edit the contents of the file. wait until you press "i, I, O, O, A, a, R, R", andso on , to enter the edit mode. Usually in Linux, when you press these keys, the words "INSERT or REPLACE" appear in the lower-left corner of the screen, so you can edit it. And if you want to go back to normal mode, you have to press the "ESC" button to exit edit mode. In this mode, in addition to the key of [ESC], the other keys can be viewed as the general input button, so you can do any editing. Instruction column Command mode:

In the general mode, enter ":/?" With any of the three buttons, you can move the cursor to the bottom row. In this model, you can provide your "search for information" motion, and the actions of reading, saving, replacing characters, leaving VI, showing lines , and so on are in this mode. The most important instruction is " : Wq ", it will save the current document and leave VI

The relationship diagram of the VI three modes

Note: General mode can be switched with edit mode and instruction column mode, but the edit mode and instruction column mode cannot be exchanged with each other

The general mode can be used by the button to say that the cursor movement, copy paste, search replace, etc.

Ways to move a cursor

h or left direction keys (←)

Rengpui move one character to the left

J or DOWN ARROW keys (↓)

Rengpui Move down one character

K or Up ARROW keys (↑)

Rengpui Move up one character

L or right direction key (→)

The cursor moves one character to the right

If you put your right hand on the keyboard, you'll notice that the HJKL are aligned, so you can use these four buttons to move the cursor. If you want to move a number of times, such as moving down 30 lines, you can use the combination of "30j" or "30↓", that is, plus the number of numbers you want to make, press the action.

[Ctrl] + [f]

The screen "downward" moves a page, as is the [pages down] button (commonly used)

[Ctrl] + [b]

The screen "Up" moves a page, as is the [pages up] button (commonly used)

[Ctrl] + [d]

Screen "Down" move half page

[Ctrl] + [u]

Screen "Up" move half page

+

RENGPUI moves to the next column of a non-whitespace character

-

RENGPUI moves to the previous column of a non-whitespace character

N<space> <

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.