Use of the VIM program editor

Source: Internet
Author: User

1. Use of VI

VI min Three modes:

    • General mode

This mode allows you to Delete, copy, paste, and search for replacements , but you cannot edit the content.

    • Edit mode

Press the ESC key to exit this mode by entering any one of the letters in I, I, O, O, A, a, R, R.

    • Instruction-column Command mode

In the general mode, enter:,/,? Any one of the letters, enter this mode, in this mode can be saved, leave VI, display line number and other actions.

  

  It is important to note that the general mode can be toggled with the edit mode and the instruction column mode, but the edit mode and the instruction column mode cannot be switched between each other.

2. Key instructions

2.1 Key instructions available for general mode

Available actions: Cursor movement, copy and paste, search and replace, etc.

Method Description
Ctrl + F Move down one page, equivalent to page down
Ctrl + b Move up one page, equivalent to page up
0 or <Home> Move to the front character of this line
$ or <End> Move to the last character of this line
G Move to the last line of the document
NG N is a number, moving to the nth row of this file, for example 20G
Gg Move to the first line of the document, equivalent to 1G
N<enter> N is a number and the cursor moves down n rows
/word Look under the cursor for a string called word
? word Look for a string with the string name word on top of the cursor
N Repeat the previous search action.
N Opposite N, the previous search action for the reverse
: n1,n2s/word1/word2/g N1 and N2 are numbers, looking for word1 between section N1 and line N2, and replacing the string with Word2
: 1, $s/word1/word2/g Full-Text Search match substitution
: 1, $s/word1/word2/gc Full-Text Search match substitution, but display prompt characters before replacement to confirm to user
X, X In one line of words, X is the backward deletion of a character (equivalent to the DEL key), and X is the deletion of one character (equivalent to the BACKSPACE key).
Nx N is a number that continuously deletes n characters backwards
Dd Delete the entire column where the cursor is located
Ndd Delete the down n column where the cursor is located
d1g Delete all data from the first row of the cursor
Dg Delete all data from the last row of the cursor
d$ Delete the last character of the cursor to the line
D0 Delete the first character of the row to which the cursor is located
Yy The line where the cursor is copied
Nyy The Down n column where the cursor is copied
y1g Copy all data from the column to the first column of the cursor
YG Copy all data from the column to the last column of the cursor
Y0 Copy all data from the same character as the cursor to the beginning of the line
y$ Copy all data at the end of the line with the same character as the cursor
P, p p to paste the copied data on the next line of the cursor, p for a row attached to the cursor
C Delete multiple data repeatedly, sunny down delete 10 lines, 10CJ
U Repeat a previous action
Ctrl + R Redo a previous action
. Repeat a previous action

2.2 General mode switch to edit mode available button description

2.3 General mode switch to command column mode available button description

:! Command Temporarily leave VI to the command column the display result of executing command
: Set Nu Show line Numbers
: Set Nonu Cancel line number

Use of the VIM program editor

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.