Learning resources from: www.magedu.com
Mistakes are unavoidable in the learning process, and if found, they are also pointed out by the great gods.
Some of the sample operations are related to historical operations, and if the previous example operation has not been performed, there may be some examples of operations that cannot be performed. Examples are for informational purposes only.
Vim Editor
Vi:visual Interface (Visual Interface)
Vim:vi Improved (VI upgrade version)
Vim : text editor, word processor, full screen editor, modal editor (in different modes, the same keystroke action is interpreted in different meanings)
Vim mode:
Edit mode (Command mode)
Input mode
Last-line mode
Mode conversion:
Edit -to-input (three common mode transitions):
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;
Input-to- edit:
ESC key
Edit-to- last line:
:
last line--edit:
ESC, ESC
Vim function:
First, open the file (default in edit mode)
# vim/path/to/somefile (parent directory must exist)
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
Example:
Cp/etc/inttab./
Vim Inittab
Vim +12 Inittab (located on line 12th)
Vim + inittab (fast on the last line)
Vim +/mul Inittab
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 (administrator)
: Wq-to: x Save and exit
2. Exit in edit mode
ZZ: Save and exit
Third, move the cursor (edit mode)
1.characterMove:
H: Left
L: Right
J: Next
K: Up
#h: Move # characters;
2. ToWordMove for unit
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
#w: Move to the beginning of the first # Word
3.in-lineJump:
0 (0): The absolute beginning of the line
^: first non-whitespace character at the beginning of a line
$: absolute end of line
4.Between rowsJump
#G: Jump to 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;
d$: Delete cursor to end of line
#dw: # words after deleting the cursor
#de,
#db
DD: Deletes the current cursor in the row
#dd: Delete the line containing the line of the current cursor;
last-line modeUnder
STARTADD,ENDADDD: Start line, end line
.: Indicates when the forward
$: Last line
+#: Down # line
Example:
1,8d: Delete 第1-8 line
., +5d: Delete the current line and the five lines down
Deleted content can be recovered, the last deleted content can be pasted to the specified location
seven, paste command p
P (lowercase): If you delete or copy the entire line, paste it below the line where the cursor is located,
If the copied or deleted content is a non-whole line, paste it to the back of the character where the cursor is located;
P (UPPERCASE): If you delete or copy the entire line, paste it above the line where the cursor is located,
If the copied or deleted content is a non-whole line, paste it in front of the character where the cursor is located;
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
10. Replace: R (replace single character)
R: Replacement mode
11. Undo Edit Operation U
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
.
13. Visualization Mode
V: Select by character
V: Select by rectangle
14. Find
/pattern
? PATTERN
n--Next
n--Previous
15. Find and replace
Use the S command in the last-line mode
Addr1,[email Protected]@[email protected]
1,$
%: Full text
16. Use Vim to edit multiple files
Vim FILE1 FILE2 FILE3
: Next switches to the next file
:p Rev Switch to the previous file
: Last switch to final file
: first to switch to file one
Example:
vim rc.sysinit inittab
:yy
next
p
:w
:p Rev
Exit
:qa all exit
17, split screen display a file
Ctrl+w, S: Horizontal splitter window
Ctrl+w, V: Vertical splitter window
Ctrl+w, ARROW: Toggles the cursor between windows
Example:
Rc.sysinit
Ctrl+w, S
Ctrl+w, arrow cursor
: QA Closes all windows
18. Edit multiple files in a window
Vim-o: Horizontal Split display
Vim-o: Vertical Split display
Example:
Vim-o Rc.sysinit Inittab
19. Save some of the contents of the current file as a different file
Use the W command in the last row mode
: W/path/to/somewhere
: Addr1,addr2w/path/to/somewhere
Example:
Vim Inittab
: 18,24w sort.txt--saves 18--24 row in Inittab as Sort.txt
: Next
: QA
vim sort.txt
20. Populate the contents of another file in the current file
:r/path/to/somefile
21, interacting with the shell
:! COMMAND
22, Advanced topic
1. Display or suppress line numbers
: Set Number
: Set Nu
: Set nonu--Cancel
2. Display ignores or distinguishes character case
: Set ignorecase
: Set ic--Ignore
: Set noic--distinguish
3. Set Auto indent
: Set Autoindent
: Set ai--Auto Indent
: Set noai--Cancel Auto Indent
4. Check the found text highlighting or canceling
: Set hlsearch--highlighting
: Set nohlsearch--Suppress highlighting
5. syntax Highlighting
: Syntax on
: Syntax off
23. Configuration Files
/etc/vimrc--Global
~/.vimrc
This article from "Not Daze" blog, please make sure to keep this source http://tobeys.blog.51cto.com/10620284/1689411
"Linux_ Notes" Linux_vim editor Common features Introduction