Vim is a text editor developed by VI
Three modes:
Three modes of command, input, last line
Command-Input mode:
A current cursor after input
A Line End Input
I cursor position input
I input at the beginning
o Cursor Next line input
O one line input on the cursor
Input, Command mode:
Esc
Command-and-last-line mode:
:
: Set NU Displays line number
: Set Nonu suppress line numbers
(Last-line mode: Set NU indicates line number)
[Email protected] kkk]#VITest.SH 1#!/bin/Bash2 Ping-C3 192.168.10.128 3 if[$?-eq0 ] 4 Then 5 Echo "The host is up!" 6 fi 7~~~: Set Nu
Last line, Command mode:
Esc
G Jump to last line
4G Jump To line fourth
GG jumps to the first line
YY Copy a row
3YY copy cursor below 3 lines
P Paste (cursor next line position)
DD Delete
3DD Delete the following 3 lines
d$ Delete to end of line
d^ Delete to the beginning of the line
DW Delete a Word
U gradually undo until text initial state
U Cancel Bank operation
ZZ Save and exit
/Find (Down)
? Find (UP)
Last-line mode operation:
W
Q
!
W/home/2.txt Save As 2.txt
! Date does not interrupt VI temporarily executes a command
E/home/3.txt Open another file
R/home/4.txt
Replace:
: Sub/root/root//First substitution per line
: sub/root/root/g//Full line replacement
:% s/root/root/g//Full text replacement
:% s/root/root/c//Full text replacement, prompt execution
Replace with ROOT (y/n/a/q/l/^e/^y)?
Vimtutor A detailed explanation of VI
Linux VI Edit