vim学习笔记

之前的一篇文章中提到在“use vim like a pro”中学习vim工具的使用,这里我记录了一些我经常用到的vim命令,做个笔记。

####use vim like a pro####
#vim shortcut key:

:q :q! :wq ZZ 	#exit current file
:qa :qa!  	#exit all opened files
vimtutor 		#open the vim tutorial
vim +23 filename  	#open file and locate the cursor at line 23
vimdiff .		#open as file browser
vi -d a.txt b.txt  	# compare the two file as a merge tool
vimdiff a.txt b.txt  	# same as -d
vim -o/-O file1 file2 ...  	# open multiple files.
ctrl+ww , ctrl+6 , ctrl+w+h/j/k/l , :bn , :bp   # change focus between files in multiple files mode
/  	# search phrase (forward searching)
?  	# search phrase (backward searching)
n , N  	# search next/previous match when searching
gg  	#put the cursor to the start of file
G   	#put the cursor to the end of file
0 , ^ 	# put the cursor to the start of current line
$  	# put the cursor to the end of current line
w/b  	# Move forward to the beginning of the next/previous word
W/B  	# Move forward to the beginning of the next/previous space-terminated word
e/E  	# Move forward to the end of the next (space-terminated) word
ctrl+f  	#move forward by page(page down)
ctrl+b  	#move backward by page(page up)
ctrl+e  	#move forward by line(by the cursor not move)
ctrl+y  	#move backward by line(by the cursor not move)
{ , }  	# move forward/backward by paragraph(separate by a space line)
( , )  	# move forward/backward by sentences(separate by a .)
[ , ]  	# move to next/previous function (in c/java/c++/python)
 %     	# move to matching brace, paren, etc
 
ctrl+n 	# in insert mode, complete a word (forward to through choice list)
ctrl+p 	# in insert mode, complete a word (backward through choice list)
* , #  	# move to next/previous instance of word under cursor
i   	# insert before the current cursor position
I   	# insert at the beginning of the current line
a   	# insert after the current cursor position
A   	# insert/append at the end of the current line
s   	# delete the character under the cursor, and enter insert mode
o   	# insert in a new line below the current line, and enter insert mode in new line
O   	# insert in a new line above the current line, and enter insert mode in new line
!   	# Enter shell filter mode
v , V , ctr+v  # mark character-wise/line-wise/column-wise
gv  	# remark the area last marked
y   	# copy the marked area
p   	# past the chosen area (start with the next position of current cursor)
d   	# delete the marked area
yy  	# copy one line
yw  	# copy current word
dd  	# delete one line
p   	# when copy one line, past it to a new line under current cursor
u   	# cancle the last operation
zt  	# move current line to the top of screen
zz  	# move current line to the middle of screen
zb  	# move current line to the bottom of screen
:e filename  	#open another file in vi
:set hlsearch  	# highlight the search result
:set ignorecase/smartcase  # set the searching result to be case insensitive/sensitive
:set nu		# show line number (or you can set in ~/.vimrc) 
:set nonu  	# hide line number (or you can set in ~/.vimrc)
:(num)		# jump to line &(num)
:+(num)   	# move the sursor forward by num lines
:-(num)   	# move the sursor backward by num lines
 

你可能感兴趣的:(vim,linux编辑器)