码迷,mamicode.com
首页 > 系统相关 > 详细

VIM手册

时间:2018-06-29 17:59:14      阅读:211      评论:0      收藏:0      [点我收藏+]

标签:code   equal   save   with   star   down   scree   character   key   

Normal mode
h //move left by one character
j //move down by one line
k //move up by one line
l //move right by one character
Ctrl + f //Page down
Ctrl + b //Page up
H   //move to the first letter of first line in current screen
M   //move to the first letter of middle line in current screen
L   //move to the first letter of last line in current screen
G   //move to the last line of the file
nG    //move to the "n" line of the file
gg    //move to the first line
n[Enter]    //move down by "n" lines
n[Space]    //move right by "n" letters
x   //delete one character afterwards, equals "Delete" key
X   //delete one character forwards, equals "Backspace" key
dd  //delete one line
ndd //delete "n" lines afterwards
nyy   //copy "n" lines starting from the cursor
p   //paste the content starting from next line
P   //paste the content before the line of cursor

command mode

/word   //find the "word" down, can using with "n"(means find next one by pressing "n" one time)
:n1,n2s/word1/word2/g   //find the "word1" and replace it with "words" between "n1" and "n2" lines
:1,$s/word1/word2/g   //find all the "word1" and replace them with "words" of file

:w [filename]    //save as file to filename
:r [filename]    //read data and insert the content after the current line of cursor
:n1,n2 w [filename]   //save the content to filename file from "n1" to "n2"
:! command    //leave vim temporary to execute command
:set nu
:set nonu

Editing blocks

v   //characters select, will select all the characters which cousor goes by
V   //line select
Ctrl + v    //block select
y   //copy the selected content
d   //delete the selected content
r  //block content replace
I  //insert content before block
A //insert content after block

Editing multi files

:n    //edit next file
:N    //edit former file
:files    //list all edited files

Multi window

:sp [filename]    //add filename(will open the file in another windown); or just :sp will open the same file in another window
Ctrl + w + j    //first press Ctrl + w, then release Ctrl and w, then press j to navigate to below window
Ctrl + w + k //first press Ctrl + w, the release both, then press k to navigate to above window

VIM手册

标签:code   equal   save   with   star   down   scree   character   key   

原文地址:http://blog.51cto.com/taoismli/2134306

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!