Reproduced from: http://blog.csdn.net/fatshaw/article/details/6170666
You can use the usual arrow keys in VIM
But there are other keys that will help you achieve your goals faster.
HJKL This is instead of the arrow keys feature
H M jumps to the top of the screen, below the middle.
W jumps to the beginning of the next word
e jumps to the end of the word
B Jump back.
GG jumps to the beginning of the file
G jump to end of file
10gg or 10G jump to line 10th
Ta jumps to the next a front
FA jumps to the next a
Uppercase means the opposite
Plus% (skip to% of file) and | (Jump to column) but I rarely use it.
The above can be prefixed by a numeric prefix representing the first few matches.
Besides PageUp PageDown, there are other quick keys when looking at files.
such as ctrl-f forward one page ctrl-b back one page
It's not important up there.
ctrl-d down half page ctrl-u up half page I think it's more practical. When you look at an article, you don't jump to error
In addition, there are
Ctrl-e Down Line
Ctrl-y up one line
^ Beginning of line
$ line End
0 first character
In addition to the above also as vim other command locator character such as delete D
Dt
Deleted to this line all the time)
Also understand the jump key after the deletion or copy is no longer in the behavior unit can be specified to a condition
I think it's a necessary way for beginners to grow up.
There's also ctrl-t Ctrl-i Ctrl]
If you've already used ctags or cscope to create an index file, it's handy to look at the code.
Jump to function, variable definition:
[+ctrl+i jumps to functions, variables, and #define
[+ctrl+d Jump to #define Place
Ctrl+i jump forward to previous cursor positions
Ctrl+o jumps back to the previous cursor position
function Body Jump:
[[
]]
[]
][
{}
2009-07-07 17:31 Supplement
How to select the contents of parentheses:
Move the cursor inside the parentheses, press Shift+v to enter the line selection mode, and then
i{-Select the contents of the parentheses, excluding the parentheses
a{-Select the contents of the parentheses, including the parentheses
IB-Select the contents in parentheses, excluding parentheses
AB-Check the parentheses for the contents, including parentheses
i{-Select the contents of curly braces, excluding curly braces
a{-Select the contents of curly braces, including curly braces
: H text-objects
Here are some tips that are not fully validated:
vi{Select the contents of {}, excluding {}
va{Select the middle content of {}, including {}
VI (SELECT () middle content
vi< Selected <> Intermediate content
vi[SELECT [] Middle content
Vit Select the middle content
VI "SELECT" "Middle content
VI ' selected ' in the middle of the content
Vis select a sentence
Vib Select a block
VIW Select a word
VIP Select a paragraph
In normal mode, the cursor stops on a character GA can view the ASCII code of the character
#复制删除粘贴的操作: Press V (shift+v), enter the visual mode, JK Select the desired line, and then press
Y replication
D Delete
X cut
P Paste
Visual mode is good, for example, to turn all the words in two lines to lowercase, press V and press J or K to select these two lines, press Gu
#跳到行首按0 but actually better use is ^, jump to the beginning of a non-white-space character
#折行前空出4字符显示折行标识
Set foldcolumn=4
#折叠或展开 (moving the cursor around the folded line can also expand the folding)
Za
#删除光标所在行所处的范围的折叠
Zd
#当在: After set Foldmethod=marker, the folding line collapses the contents between {{and}}}
#不在单词中间断行. When this option is set, if a line of text is very long and cannot be displayed in one line,
It breaks the gap between words and words, trying not to divide a word into two or two different lines.
Set LBR
#sw是shiftwidth的缩写, number of table indent columns
FX moves the cursor to the next X character of the line, and this x can be a Chinese character, and the FX operation is repeated. FX moves the cursor to the previous X character on the line.
The GG cursor navigates to the beginning of the first line, and G navigates to the last line.
The H cursor jumps to the current window to display the first line of text
The M cursor jumps to the middle line of the current window display text
The L cursor jumps to the last line of display text in the current window
g* Find all the words that contain the current word (* Find only the exact words that match the current word).
-D cursor down half screen, text roll half screen
-U-cursor jumps half screen, text bottom roll half screen
-E text scrolls up one line
ZZ Screen Scrolling makes the current row the middle row of the screen
In normal mode, press J to delete line breaks at the end of this line, merging two lines
: e! reread the last saved contents of this file
: AB myname WILLIAM_DJJ
Type myname When you edit it later, and then the space or carriage return myname string will be WILLIAM_DJJ instead
: R!date
Inserts the system time at the current position (the date command under Linux), the same as the current position inserts a file in the content is
: R filename
: Set ignorecase
Cancel case sensitive when looking
: Set Noignorecase
Case sensitive when looking
############ Use tags ###################
The following command recursively lists all files in the current directory to create tags files
Ctags-r.
Vim opens any file in the current directory, and in command mode, type the following statement to specify the location of tags you just created, and then consult the functions between different files
Set tags= ... /tags
#分割窗口显示当前函数的定义
-W]
##########################################
If there is a echofunc.vim in the plugin directory to generate tags under the command, later edit the code function name and then hit "(" when the parameter prompts.)
$ ctags-r–fields=+ls.
: Tlist opens a taglist window on the left, showing symbols. Note that under Windows if tags file path has a space or Chinese will report can't find tags file error,
+w+w or +w+left/right window switch
+] Enter the definition of symbol that the cursor refers to (if you use the mouse is also + the left mouse button, like the use of Si)
+t returns the first +t jump position, note that +o is jumping back to the previous view, and +t is jumping back to the last pressed +] position
#以下命令分裂出一个窗口显示定义处
PTag Name of the letter
#以下命令关闭刚才打开的分裂窗口
Pclose
#垂直分裂窗口打开一文件
Vsplit file name
#水平分裂窗口打开一文件
Split file name
Variable name written as/name expression matching pattern
Stop on a bracket by%, jump to a matching bracket, #if跳到匹配的 #else or #endif
Set Fdm=syntax collapse function body
Double-click the function to skip and double-click
#解决乱码
Set Fileencodings=ucs-bom,utf-8,cp936,gb18030,big5,euc-jp,euc-kr,latin1
#在vim下对比两个文件, turned on the fnpro.c, and now contrasts with Fnpro.c.bak
#垂直分割
: Vert Diffsplit Fnpro.c.bak
#水平分割
:d Iffsplit Fnpro.c.bak
#跳到下一个不同之处
:]c
#跳到上一个不同之处
: [C
#展开折叠: Zo
#折叠: ZC
The place where #不论何种情况下-O can be jumped once
#查看变量和函数的申明
[I
#以下为查看vim环境参数makeprg的值的例子:
: Set MAKEPRG?
#重新对文件代码进行缩进
Gg=g
Jump to function , variable definition:
[+ctrl+i jumps to functions , variables, and #define
[+ctrl+d Jump to #define Place
Ctrl+i Jump forward to previous cursor positions
Ctrl+o jumps back to the previous cursor position
function Body jump :
[[
]]
[]
][
{}
2009-07-07 17:31 Supplement
How to select the contents of parentheses:
Move the cursor inside the parentheses, press Shift+v to enter the line selection mode, and then
i{-Select the contents of the parentheses, excluding the parentheses
a{-Select the contents of the parentheses, including the parentheses
IB-Select the contents in parentheses, excluding parentheses
AB-Check the parentheses for the contents, including parentheses
i{-Select the contents of curly braces, excluding curly braces
a{-Select the contents of curly braces, including curly braces
: H text-objects
Here are some tips that are not fully validated:
vi{Select the contents of {}, excluding {}
va{Select the middle content of {}, including {}
VI (SELECT () middle content
vi< Selected <> Intermediate content
vi[SELECT [] Middle content
Vit Select the middle content
VI "SELECT" "Middle content
VI ' selected ' in the middle of the content
Vis select a sentence
Vib Select a block
VIW Select a word
VIP Select a paragraph
Vim file Jump
If you use vim to open more than one file , such as Vim file1 file2 ... filen
can go through
: N or:p Rev to jump to the previous or last file
You can also jump to the first and final file
If you only open one file, such as Vim File1
Then, in use, the second file is edited through
: E file2, at which point:p rev is not working
can be used
: e# to return to the previous edited file
Either way you can use
: bn to jump to the first n file you open
such as: B1 jumps to the first open file