The move keys available in VI Command mode:
h---move the cursor one character to the left
j---move the cursor down one character
k---move the cursor up one character
l---move the cursor one character to the right
w---move the cursor forward one word
b---move the cursor back one word
e---move the cursor after the next word
0---move the cursor to the beginning of the line
$---move the cursor to the end of the line
---Move the cursor to the next sentence
(----Move the cursor to the first sentence
}---move the cursor to the beginning of the next paragraph
{---move the cursor to the beginning of the next paragraph
g---move the cursor to the bottom of the current document
^---moves the cursor to the first character in the line that is not a space
h---move the cursor to the first line on the screen
l---move the cursor to the last line on the screen
Scroll the screen in VI:
Z then press ENTER---Move the line of the cursor to the top of the screen
Z then press "-"---move the line of the cursor to the bottom of the screen
Z and press "." --Move the line of the cursor to the middle of the screen
Ctrl u------scroll up half screen
Ctrl d------scroll down half screen
Ctrl f------Scroll forward full screen
Ctrl b------Scroll back to full screen
Ctrl e------scroll down one line
Ctrl y------scroll up one line
VI's text Edit command:
d------Delete text from the end of the line positioned by the cursor
dd------row Delete cursor positioning of the forward
Ndd-----n represents the number of rows that will be deleted. For example, the 5DD command will not only delete the current line, but also delete the following 4 lines
Rc------c represent characters. The character below the cursor will be replaced with the characters following R
The text you type after r------r overwrites the current text, starting at the cursor position until you press Escape to return to command mode
s------deletes the current line and begins inserting text in the current blank line
x------Delete the character below the cursor and move the word Fu Yi to the blank
x------deletes the character before the cursor and moves the character so that the characters below the cursor fill in the blanks
~------change the case of the letter under the cursor
j------connects the current row to the previous line and deletes the resulting blank line
File Operations in VI:
zz------save changes to the current file and Exit VI
: wq-----saves changes to the current file and then exits VI (same as ZZ)
: w------save changes to the current file
: w!-----to save changes to the current file, if there is a file with the same name, rewrite him
: q------Exit VI. If there are unsaved changes, VI will issue a complaint and "refuse" to exit
: q!-----exit VI, even if there are unsaved changes. All unsaved changes will be lost
: e filename-The specified file into VI for editing. If the specified file does not exist, a new file is created
: e!-----loses all changes and overloads the saved file from the hard disk
Find and Replace commands in VI
/pattern--------pattern (style) refers to what you are looking for. VI will look forward in the file to the first style that matches the specified content
/-----------repeats the last lookup and finds the next matching style in the file
? Pattern--------pattern (style) refers to the content to look for. VI will look backwards in the file for the first style that matches the specified content
?-----------repeats the last lookup and finds the style in the file that matches the last find content
%-----------moves the current cursor to a matching parenthesis or square bracket. This command is useful for programmers
: s/pattern1/pattern2--replaces each content in the current row with the PATTERN1 with pattern2
:%s/pattern1/pattern2--replaces each content in the entire file with the PATTERN1 with pattern2
The Yank command in VI
yw-------Move the word that is currently in the cursor to the buffer
y$-------moves the current line and all previous text to the buffer
yy-------move the current line whole line to the buffer
Nyy-------n represents the number of lines of text to be moved to the buffer. For example, 5yy moves the current line and the 4 lines immediately following to the buffer
1, the new file vi path file name can be
2, edit the file, a little trouble, open the file, input I start editing text, carriage return is a newline. : W is to save the file, if you exit edit state after Press W is a word back. Note that if you press ESC in edit State, Exit and then enter: W return, which is saved.
2,: Q is an exit, and when there are no unsaved changes, it will use
3,: q! is out and not saved.
4, u can cancel the modification just now, Ctrl+r can cancel the modification that you cancel.
Note: The command with: number is ESC first, then: Command carriage return execution, without:, is ESC and then enter execution.
5, forget what is currently editing the file, you can use Ctrl+g to view.
6, VI can execute the command. :!command can execute commands. When the command is complete, you can return it by pressing ENTER. The
can even use the shell in VI, (:. BASH) after executing several commands from the shell, exit returns to VI.
7, save exit, ZZ or: Wq.
Delete:
8, delete the line d$, remove the text from the cursor to the end of the line.
D0 deletes text from the cursor to the beginning of the line. ,
9, x delete a character after the cursor
10, x directly delete the cursor before a character
11, DW deletes all characters starting from the current character until the end of the word.
Direction key:
12, H left L right J down K, with the direction of the key function, but can add numbers to run. If you move down 12 lines, 12j.
13, W to the beginning of the next word.
14, B to the beginning of the previous word. The
15, 0 moves the cursor to the beginning of the current line.
16, $ to the end of the current line
17, h to the top left corner of the screen
18, m to the middle of the screen in the first character
19, l to the last line of the screen
most of the commands before the number can be added.
3dw deleted 3 words