(Turn) Literacy Action IX: VI Editor basic use Method!

Source: Internet
Author: User

The VI Editor is the standard editor for all UNIX and Linux systems, and its power is not inferior to any of the latest text editors, here is simply a brief introduction to its usage and a small number of instructions. Because the VI editor is exactly the same for any version of UNIX and Linux systems, you can learn more about it in any other place where VI is introduced. VI is also the most basic text editor in Linux, after learning it, you will be in the world of Linux unimpeded.

1, VI of the basic concept
Basically, vi can be divided into three states, namely command mode, insert mode (and bottom line mode), and the function of each mode is as follows:

1) command-line mode

Controls the movement of the screen cursor, the deletion of characters, words, or lines, moving and copying a section and entering insert mode, or to last line mode.

2) Insert mode

Only in the Insert mode, you can do text input, press "esc" to return to the command line mode.

3) Bottom Line mode

Save or Exit VI, or you can set the editing environment, such as looking for a string, listing line numbers ... such as

In general, however, we simplify the VI into two modes when we use it, that is, the bottom row mode (last line mode) is also counted as the command-line pattern.

2, VI of the basic operation
A) Enter VI

After the system prompt symbol to enter VI and file name, go to the VI Full screen editing screen:

$ VI myfile


However, it is important to note that after you enter VI, you are in command mode.ToggleTo insert mode to enter text. The first person who uses VI will want to first move the cursor with the upper and lower keys,The computer always beeps ., put yourself in a half-dead, so enter VI, do not move, switch to "insert mode" and then again!

b) switch to insert mode to edit the file

Under command-line modePress the letter "i"You can enter "Insert mode" and you can start typing.

c) Toggle of Insert

You are currently in insert mode, you can only enter text all the time,If you find that you have lost the wrong word! To move back with the cursor key, delete the wordIsClick the "esc" button to go toCommand mode to delete the text.

Dexit VI and save file

Under command-line mode,Press the ":", please .The colon key enters "last line mode", for example:

: w filename (enter "w filename" to save the article with the filename you specified)

: Wq (input "wq", save and Exit VI)

: q! (Enter q!, do not save the mandatory exit VI)

3. Command mode function key
1). Insert mode

Press "i" switch into insert mode "insert mode", press "I" into the insertion mode is the beginning of the cursor from the current position to enter the file;

After pressing "a" into insert mode, the text is entered from the next position at the current cursor position;

When you press "o" to enter insert mode, you insert a new line and enter text from the beginning of the beginning.

2). Switch from insert mode to command line mode

Press the "esc" key.

3). Move the cursor

VI can be directly on the keyboard with the cursor to move up and down, but the normal VI is the lowercase English letter "h", "j", "k", "l", respectively, control the cursor left, bottom, upper, and right one grid.

Press "ctrl"+"b": The screen moves one page to the back.

Press "ctrl"+"f": The screen moves one page to the front.

Press "ctrl"+"u": The screen moves the half page toward the back.

Press "ctrl"+"d": The screen moves the half page toward the front.

 

  For the first use VI, there are a few notes to remind:
1. When you open a file with VI, you are in command mode, and you want to switch to insert mode to enter text. Toggle method: Click on the letter "i" "Command mode" to enter "Insert Mode", then you can start to enter the text.
2, after editing, you need to switch from insert mode to command line mode in order to save the file, switch method: Press the "esc" key.
3. Save and exit the file: Enter in command mode: WQ! (Don't forget to wq the front:)

Here I've only looked for commands that are useful to me, and you can see them in detail.

Http://linux.chinaunix.net/doc/office/2005-01-24/898.shtml

(Turn) Literacy Action IX: VI Editor basic use Method!

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.