Linux Learning Notes 13--vi and VIM editor

Source: Internet
Author: User
Tags exit in

Vi:visual Interface Visual Interface
VIM:VI improved: Enhanced version VI recommended use!!!
Full screen editor, modal editor

Vim mode: In different modes, the meaning of the knocked-down thing is not the same.
Edit mode (Command mode)
Input mode
Last-line mode

Mode conversion:
Edit--Input:
I: In front of the character of the current cursor, switch to input mode;
A: After the character of the current cursor, switch to input mode;
O: At the bottom of the current cursor line, create a new row and switch to input mode;
I: Converted to input mode at the beginning of the line at which the cursor is currently located
A: At the end of the line where the current cursor is located, convert to input mode
O: At the top of the current cursor line, create a new row and switch to input mode;

Edit-to-last line:

Input-to-edit:
Esc

Last line--edit:
ESC, ESC

First, open the file
Vim/path/to/somefile
Vim +#: Open the file and locate it on line #
Vim +: Open the file and navigate to the last line
Vim +/pattern: Open the file and navigate to the beginning of the line that was first matched to the PATTERN
Default in edit mode

Second, close the file
1, the last line mode closed file
: Q exit
: Wq Save and exit
: q! Do not save and exit
: W Save
: w! Forcibly saved
: Wq---: X
2. Exit in edit mode
ZZ: Save and exit

Third, move the cursor (edit mode)
1, character-by-word movement: (the next key or the same can)
H: Left
L: Right
J: Next
K: Up
#h: Move # characters;

2. Move in Word units
W: Move to the beginning of the next word
E: Jumps to the ending of the current or next word
B: Jump to the beginning of the current or previous word
nw
The above command can be preceded by a number, the number of moves

3, in-line jump: (can be combined with the subsequent deletion of the copy and other operations)
0: The absolute beginning
^: first non-whitespace character at the beginning of a line
$: absolute end of line

4. Jump between rows
NG: Jump to Nth line;
G: Last line
In the last line mode, directly to the travel number can be

Four, turn the screen
CTRL+F: Flip one screen down
Ctrl+b: Turn up one screen

Ctrl+d: Flip Down half screen
Ctrl+u: Flip up half screen

V. Delete a single character
X: Delete a single character at the cursor location
#x: Remove the total # characters from the cursor and backwards

Vi. Delete command: D
The D command is used in combination with the jump command;
#dw, #de, #db

DD: Deletes the current cursor in the row
#dd: Delete the line containing the line of the current cursor;

In the last line mode:
STARTADD,ENDADDD (eg: 1,10d)
.: Indicates when the forward
$: Last line
+#: Down # line

Seven, Paste command p
P: If you delete or copy to a whole line, paste to the bottom of the line where the cursor is located, and if the copied or deleted content is a non-full line, paste it behind the character of the cursor;
P (uppercase): if deleted or copied as an entire line, paste to the top of the line where the cursor is located, and if the copied or deleted content is a non-full row, paste it in front of the character in the cursor;

Eight, copy command y
Usage with d command

Nine, modify: First delete the content, and then converted into the input mode
C: Usage with d command

X. Replace: R replaces a single character
R: Replace mode can replace multiple characters in this mode

Xi. undo Edit Operation U (undo)
U: Undo the previous edit operation
The continuous u command undoes the previous n edit operations
#u: Undo Recent # edits directly

Undo the most recent undo action: Ctrl+r

12. Repeat the previous edit operation
Dot character.

13, the visualization mode is used to delete the copy and paste operations
V: Select by character
V: Select by rectangle

14, find (support regular expression, in the last row mode)
/pattern from yourselves to tail
? PATTERN from current to header
N: Find from top to bottom
N: Find from bottom to top

XV, find and replace

 在末行模式下使用s命令(sed中的command的s) ADDR1,[email protected]@[email protected] 1,$ %:表示全文

Linux Learning Notes 13--vi and VIM 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.