实用手册130+提高开发效率的vim常用饬令

发布时间:2025-04-21 点击:3
百度权重查询 词库网 网站监控 服务器监控 seo监控 手机游戏 iphone游戏
基本饬令
:e filenameopenfilenamefor edition:wsave file:qexit vim:q!quit without saving:xwrite file (if changes has been made) and exit:sav filenamesaves file asfilename.repeats the last change made in normal mode5.repeats 5 times the last change made in normal mode在文件中移动
k or up arrowmove the cursor up one linej or down arrowmove the cursor down one lineemove the cursor to the end of the wordbmove the cursor to the begining of the word0move the cursor to the begining of the linegmove the cursor to the end of the fileggmove the cursor to the begining of the filelmove the cursor to the bottom of the screen:59move cursor to line59. replace59by the desired line number.20|move cursor to column20.%move cursor to matching parenthesis[[jump to function start[{jump to block start剪切、拷贝和粘贴
ycopy the selected text to clipboardppaste clipboard contentsddcut current lineyycopy current liney$copy to end of linedcut to end of line搜索
/wordsearchwordfrom top to bottom?wordsearchwordfrom bottom to top*search the word under cursor/\cstringsearchstringorstring, case insensitive/jo[ha]nsearchjohnorjoan/\< thesearch the, theatre orthen/the\>searchtheorbreathe/\< the\>searchthe/\< ¦.\>search all words of 4 letters/\/searchfredbut notalfredorfrederick/fred\|joesearchfredorjoe/\<\d\d\d\d\>search exactly 4 digits/^\n\{3}find 3 empty lines:bufdo /searchstr/search in all open filesbufdo %s/something/somethingelse/gsearchsomethingin all the open buffers and replace it withsomethingelse替代
:%s/old/new/greplace all occurences ofoldbynewin file:%s/onward/forward/gireplace onward by forward, case unsensitive:%s/old/new/gcreplace all occurences with confirmation:2,35s/old/new/greplace all occurences between lines 2 and 35:5,$s/old/new/greplace all occurences from line 5 to eof:%s/^/hello/greplace the begining of each line byhello:%s/$/harry/greplace the end of each line byharry:%s/onward/forward/gireplaceonwardbyforward, case unsensitive:%s/ *$//gdelete all white spaces:g/string/ddelete all lines containingstring:v/string/ddelete all lines containing which didn’t containstring:s/bill/steve/replace the first occurence ofbillbystevein current line:s/bill/steve/greplacebillbystevein current line:%s/bill/steve/greplacebillbystevein all the file:%s/^m//gdelete dos carriage returns (^m):%s/\r/\r/gtransform dos carriage returns in returns:%s#<[^>]\+>##gdelete html tags but keeps text:%s/^\(.*\)\n\1$/\1/delete lines which appears twicectrl+aincrement number under the cursorctrl+xdecrement number under cursorggvgg?change text to rot13大小写
vulowercase linevuuppercase lineg~~invert caseveuswitch word to uppercaseve~modify word casegggugset all text to lowercasegggugset all text to uppercase:set ignorecaseignore case in searches:set smartcaseignore case in searches excepted if an uppercase letter is used:%s/\<./\u&/gsets first letter of each word to uppercase:%s/\<./\l&/gsets first letter of each word to lowercase:%s/.*/\u&sets first letter of each line to uppercase:%s/.*/\l&sets first letter of each line to lowercase读写文件
:1,10 w outfilesaves lines 1 to 10 inoutfile:1,10 w >> outfileappends lines 1 to 10 tooutfile:r infileinsert the content ofinfile:23r infileinsert the content ofinfileunder line 23文件浏览器
:e .open integrated file explorer:sexsplit window and open integrated file explorer:sex!same as:sexbut split window vertically:browse egraphical file explorer:lslist buffers:cd ..move to parent directory:argslist files:args *.phpopen file list:grep expression *.phpreturns a list of .php files conteningexpressiongfopen file name under cursor和 unix 系统交互
:!pwdexecute thepwdunix command, then returns to vi!!pwdexecute thepwdunix command and insert output in file:shtemporary returns to unix$exitretourns to vi对齐
:%!fmtalign all lines!}fmtalign all lines at the current position5!!fmtalign the next 5 lines选项卡/窗口
:tabnewcreates a new tabgtshow next tab:tabfirstshow first tab:tablastshow last tab:tabm n(position)rearrange tabs:tabdo %s/foo/bar/gexecute a command in all tabs:tab ballputs all open files in tabs:new abc.txteditabc.txtin new window分屏显示
:e filenameeditfilenamein current window:split filenamesplit the window and openfilenamectrl-w up arrowputs cursor in top windowctrl-w ctrl-wputs cursor in next windowctrl-w_maximize current window verticallyctrl-w|maximize current window horizontallyctrl-w=gives the same size to all windows10 ctrl-w+add 10 lines to current window:vsplit filesplit window vertically:sview filesame as:splitin readonly mode:hideclose current window:­nlyclose all windows, excepted current:b 2open #2 in this window主动完成
ctrl+n ctrl+p (in insert mode)complete wordctrl+x ctrl+lcomplete line:set dictionary=dictdefinedictas a dictionnaryctrl+x ctrl+kcomplete with dictionnary标记
m {a-z}marks current position as{a-z}' {a-z}move to position{a-z}''move to previous position缩写
:ab mail mail@provider1438definemailas abbreviation ofmail@provider1438文本缩进
:set autoindentturn on auto-indent:set smartindentturn on intelligent auto-indent:set shiftwidth=4defines 4 spaces as indent sizectrl-t, ctrl-dindent/un-indent in insert mode>>indent<<un-indent=%indent the code between parenthesis1gvg=indent the whole file代码高亮
:syntax onturn on syntax highlighting:syntax offturn off syntax highlighting:set syntax=perlforce syntax highlighting

总结网站设计中要注意的问题
企业为什么要建网站呢?
图片优化可以提高seo的搜索排名效果吗?
稳定的香港云服务器多少钱一个月?
怎么选择好的网站托管公司呢?
怎样建立网站转化目标
整站SEO优化的操作步骤
网站优化中网站流量的获取方法解析