Move the cursor (editing mode)
1. Move the cursor
h Left
Right l
j at
the K
#h: moving characters #
2, the row jump
0: absolute beginning of the line
$: The absolute end of the line
first non-blank character ^ beginning of the line
3. Line jump between
gg first row
G last row
#G: Go to the line #
4. Delete a single character
x Delete character by character (and deleting a single character at the cursor backward)
NX n characters specified delete (delete the cursor and rearwardly of n characters total)
nX: Delete at the cursor and forward a total of n characters
5. Delete a command line
dd delete a single line (cut) to delete the current cursor line
NDD n rows deleted (shear) comprises deleting the current line n lines, including the cursor
line mode n, md delete specified (cutting) line positions
PS adhesive bond may be p
6. copy paste
yy single line cut
nyy n line shear
PS adhesive bond may be p
7. Replace command
r replace single character
R replace a plurality of characters
8. undo command
before the editing operation u undo the last operation
Continuous u command may undo the previous editing operation n times (up to 50 operations)
NU undo recent edits n times
undo just undone (a return to the last undone): ctrl + r
9. visualization mode
v Press selected character
V to select a rectangular
PS y replication
PS p paste
PS u all lowercase letters
PS U all uppercase letters
PS> indented to the right
PS <Indent Left
10. Find
the last line mode:
/ PATTERN: backward search string PATTERN
? PATTERN: forward search string PATTERN
- n: the display information matching one by one down to
- N: up to match the information displayed one
11. Search and Replace
line mode:
n-, MS / Old / new new / or GI or s @@@ s %%%
ps: i represents a case-insensitive lookup, I represents case sensitive; PS: n-: start line m: end line of old: the information wants to select matched new: the information wants to change the PS: the second row to Article in a row all replaced b: 2 , 20S / a / b / G PS:.: $ represent the current line: the last line %: full representation
#, $ @ / old / new /: from the current # to the last row replacement
12. The use of a plurality of files vim editor
vim file1 file2 file3
the PS: first open file1, file2 To edit, can be input next in line mode
, if there are many documents, you can enter last (the last text line mode ) first (first file) or the like corresponding to the English
If there are many files, you can enter in line mode
- : next switch to the next file: prev before switching to a file: Last switch to the last file: first switch to the first file exit: qa all out
13. The split-screen display a file
vim -o file1 file2
+ Ctrl W + down key, toggle window Ctrl + W + S horizontal split window Ctrl + W + V vertical split window switch between windows cursor Ctrl + WW switch window Ctrl + W Q to exit the current window
Vim do not save the file before the actual changes, just loaded into the buffer, edit the file is actually edit buffer until: to be credited when the physical files w
14. The exchange with the shell
line mode:
! COMMAND (shell to be executed)
15. The High conversation
line mode:
display or cancel the line numbers: set nu show canceled set nonu
set automatic indentation: Set set ai cancel set noai
found text message highlighted: setting set hlsearch cancel set nohlsearch
grammar highlight: set syntax on syntax off canceled
16. File Encryption
line mode:
setting X
Cancel X has a carriage return
17. The configuration file
/ etc / vimrc global file
~ / .vimrc in your home directory only to the user settings
More details, please refer to: http: //note.youdao.com/noteshare id = 04b6d3beacfd1f5c0aa14485c32cf4a7 & sub = 11F0136F9D0548C38A0DD116EC80D654?
File color and type
of different meanings in different color document represents:
white: normal color
red: the compressed file
Yellow: device file (/ dev directory under)
Cyan: link files
Turquoise: executable files
green yellow: pipe file
Pink : image file or a socket (denoted by s)
file types:
-: normal file
L (lowercase L): link file
B: block file] [block device file
c: character device file
P: pipe file