vim基础使用介绍

上传人:第*** 文档编号:34192221 上传时间:2018-02-21 格式:DOCX 页数:12 大小:623.41KB
返回 下载 相关 举报
vim基础使用介绍_第1页
第1页 / 共12页
vim基础使用介绍_第2页
第2页 / 共12页
vim基础使用介绍_第3页
第3页 / 共12页
vim基础使用介绍_第4页
第4页 / 共12页
vim基础使用介绍_第5页
第5页 / 共12页
点击查看更多>>
资源描述

《vim基础使用介绍》由会员分享,可在线阅读,更多相关《vim基础使用介绍(12页珍藏版)》请在金锄头文库上搜索。

1、一、 Vim 没有菜单,只有命令。是一款全屏幕模式文本编辑器。二、 VIM 工作模式三、 插入模式:在命令模式按 i;进入编辑模式:在命令模式 shift+:。四、 命令:四、使用技巧基础:e filename Open filename for edition:w Save file:q Exit Vim:q! Quit without saving:x Write file (if changes has been made) and exit:sav filename Saves file as filename. Repeats the last change made in norm

2、al mode5. Repeats 5 times the last change made in normal mode在文件中移动k or Up Arrow move the cursor up one linej or Down Arrow move the cursor down one linee move the cursor to the end of the wordb move the cursor to the begining of the word0 move the cursor to the begining of the lineG move the cursor

3、 to the end of the linegg move the cursor to the begining of the fileL move the cursor to the end of the file:59 move cursor to line 59. Replace 59 by the desired line number.20| move cursor to column 20.% Move cursor to matching parenthesis Jump to function start Jump to block start剪切、复制和粘贴y Copy t

4、he selected text to clipboardp Paste clipboard contentsdd Cut current lineyy Copy current liney$ Copy to end of lineD Cut to end of line搜索/word Search word from top to bottom?word Search word from bottom to top* Search the word under cursor/cstring Search STRING or string, case insensitive/johan Sea

5、rch john or joan/ Search the or breathe/ Search the/ Search all words of 4 letters/ Search fred but not alfred or frederick/fred|joe Search fred or joe/ Search exactly 4 digits/n3 Find 3 empty lines:bufdo /searchstr/ Search in all open filesbufdo %s/something/somethingelse/gSearch something in all t

6、he open buffers and replace it withsomethingelse替换:%s/old/new/g Replace all occurences of old by new in file:%s/onward/forward/gi Replace onward by forward, case unsensitive:%s/old/new/gc Replace all occurences with confirmation:2,35s/old/new/g Replace all occurences between lines 2 and 35:5,$s/old/

7、new/g Replace all occurences from line 5 to EOF:%s/hello/g Replace the begining of each line by hello:%s/$/Harry/g Replace the end of each line by Harry:%s/onward/forward/gi Replace onward by forward, case unsensitive:%s/ *$/g Delete all white spaces:g/string/d Delete all lines containing string:v/s

8、tring/d Delete all lines containing which didnt contain string:s/Bill/Steve/ Replace the first occurence of Bill by Steve in current line:s/Bill/Steve/g Replace Bill by Steve in current line:%s/Bill/Steve/g Replace Bill by Steve in all the file:%s/M/g Delete DOS carriage returns (M):%s/r/r/g Transfo

9、rm DOS carriage returns in returns:%s#+#g Delete HTML tags but keeps text:%s/(.*)n1$/1/ Delete lines which appears twiceCtrl+a Increment number under the cursorCtrl+x Decrement number under cursorggVGg? Change text to Rot13大小写Vu Lowercase lineVU Uppercase lineg Invert casevEU Switch word to uppercas

10、evE Modify word caseggguG Set all text to lowercasegggUG Set all text to uppercase:set ignorecase Ignore case in searches:set smartcase Ignore case in searches excepted if an uppercase letter is used:%s/ outfile Appends lines 1 to 10 to outfile:r infile Insert the content of infile:23r infile Insert

11、 the content of infile under line 23文件浏览器:e . Open integrated file explorer:Sex Split window and open integrated file explorer:Sex! Same as :Sex but split window vertically:browse e Graphical file explorer:ls List buffers:cd . Move to parent directory:args List files:args *.php Open file list:grep e

12、xpression *.php Returns a list of .php files contening expressiongf Open file name under cursor和 Unix 系统交互:!pwd Execute the pwd unix command, then returns to Vi!pwd Execute the pwd unix command and insert output in file:sh Temporary returns to Unix$exit Retourns to Vi对齐:%!fmt Align all lines!fmt Ali

13、gn all lines at the current position5!fmt Align the next 5 linesTabs/Windows:tabnew Creates a new tabgt Show next tab:tabfirst Show first tab:tablast Show last tab:tabm n(position) Rearrange tabs:tabdo %s/foo/bar/g Execute a command in all tabs:tab ball Puts all open files in tabs:new abc.txt Edit a

14、bc.txt in new window分屏显示:e filename Edit filename in current window:split filename Split the window and open filenamectrl-w up arrow Puts cursor in top windowctrl-w ctrl-w Puts cursor in next windowctrl-w_ Maximize current window verticallyctrl-w| Maximize current window horizontallyctrl-w= Gives th

15、e same size to all windows10 ctrl-w+ Add 10 lines to current window:vsplit file Split window vertically:sview file Same as :split in readonly mode:hide Close current window:nly Close all windows, excepted current:b 2 Open #2 in this window自动完成Ctrl+n Ctrl+p (in insert mode) Complete wordCtrl+x Ctrl+l

16、 Complete line:set dictionary=dict Define dict as a dictionnaryCtrl+x Ctrl+k Complete with dictionnaryMarksm a-z Marks current position as a-z a-z Move to position a-z Move to previous position缩写:ab mail mailprovider.org Define mail as abbreviation of mailprovider.org文本缩进:set autoindent Turn on auto-indent:set smartindent Turn on intelligent auto-indent:set shiftwidth=4 Defines 4

展开阅读全文
相关资源
正为您匹配相似的精品文档
相关搜索

最新文档


当前位置:首页 > 办公文档 > 解决方案

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号