Menu Home

vim 使用技巧



1. ctrl + v 进入可视块选择,使用上下左右键选择需要注释的行
2. shift + i 进入插入模式
3. 输入注释符号 eg. //
4. ESC


1. ctrl + v 进入可视块选择,使用上下左右键选择需要取消注释行的注释符
2. d 删除注释符号


vim 提供 6中折叠方式(set fmd=****):
manual 手工定义折叠
indent 更多的缩进表示更高级别的折叠
expr 用表达式来定义折叠
syntax 用语法高亮来定义折叠
diff 对没有更改的文本进行折叠
marker 对文中的标志折叠
zc 折叠
zC 对所在范围内所有嵌套的折叠点进行折叠
zo 展开折叠
zO 对所在范围内所有嵌套的折叠点展开
[z 到当前打开的折叠的开始处。
]z 到当前打开的折叠的末尾处。
zj 向下移动。到达下一个折叠的开始处。关闭的折叠也被计入。
zk 向上移动到前一折叠的结束处。关闭的折叠也被计入。
zf 创建折叠,比如在marker方式下:
zd 删除 (delete) 在光标下的折叠。仅当 ‘foldmethod’ 设为 “manual” 或 “marker” 时有效。
zD 循环删除 (Delete) 光标下的折叠,即嵌套删除折叠。
仅当 ‘foldmethod’ 设为 “manual” 或 “marker” 时有效。
zE 除去 (Eliminate) 窗口里“所有”的折叠。
仅当 ‘foldmethod’ 设为 “manual” 或 “marker” 时有效。


cnext : 下一个出错误的地方
cprevious : 回到上一个错误的地方
clast : 最后一个出错的地方
crewind : 第一个出现错误的地方
cnfile :
cc : 显示出错信息
clist : 错误的列表
:clist3,5 显示第三行到第五行的错误
:clsit,5 显示第一行到第五行的错误
:clsist5, 显示第五行到最后一行的错误

vim 调整窗口高度和宽度

CTRL-W = 使得所有窗口 (几乎) 等宽、等高,但当前窗口使用 ‘winheight’ 和 ‘winwidth’。

:res[ize] -N
CTRL-W – 使得当前窗口高度减 N (默认值是 1)。如果在 ‘vertical’ 之后使用,则使得宽度减 N。

:res[ize] +N
CTRL-W + 使得当前窗口高度加 N (默认值是 1)。如果在 ‘vertical’ 之后使用,则使得宽度加 N。

:res[ize] [N]
CTRL-W _ 设置当前窗口的高度为 N (默认值为最大可能高度)。

CTRL-W <; 使得当前窗口宽度减 N (默认值是 1)。
CTRL-W >; 使得当前窗口宽度加 N (默认值是 1)。

CTRL-W-H 将窗口移到最左边
CTRL-W-L 将窗口移到最右边
CTRL-W-J 将窗口移到底端
CTRL-W-K 将窗口移到顶端


i :在光标前
I :在当前行首






warn:在转到别的文件时若没保存当前文件则显示NO write信息


:n1,n2 co n3:将n1行到n2行之间的内容拷贝到第n3行下
:n1,n2 m n3:将n1行到n2行之间的内容移至到第n3行下
:n1,n2 d :将n1行到n2行之间的内容删除
:w :保存当前文件
:e filename:打开文件filename进行编辑
:n1,n2 w!command:将文件中n1行至n2行的内容作为command的输入并执行之,若不指定n1,n2,则表示将整个文件内容作为command的输入
:pwd : 查看当前编辑文件的路径




格式化代码: gg=G


先按下数字 1 , 然后按下组合键 CTRL + shift + g



Vim默认是贪婪匹配,使用:h non-greedy查看帮助文档会发现可以使用下面的方法来使用最小匹配:


12 replies

  1. My spouse and i ended up being absolutely peaceful that Peter could finish off his studies because of the ideas he received out of the web page. It is now and again perplexing to simply be handing out tactics which people might have been trying to sell. And we also know we have the writer to give thanks to for this. All of the explanations you made, the straightforward blog menu, the friendships your site assist to instill – it’s most incredible, and it’s really aiding our son in addition to the family recognize that this concept is excellent, and that is extraordinarily essential. Thank you for the whole lot!

  2. Thank you for your whole work on this blog. Kim take interest in getting into investigation and it’s simple to grasp why. We hear all of the dynamic mode you offer very helpful secrets by means of the website and encourage participation from others on that subject while our girl is in fact discovering a lot of things. Take pleasure in the remaining portion of the year. You’re performing a pretty cool job.

  3. I actually wanted to construct a brief word in order to say thanks to you for some of the fantastic tips and hints you are giving out here. My time intensive internet investigation has finally been paid with wonderful facts and strategies to talk about with my two friends. I ‘d tell you that we website visitors are undoubtedly endowed to be in a really good site with so many wonderful professionals with very helpful opinions. I feel extremely happy to have encountered your website and look forward to really more entertaining times reading here. Thanks once again for everything.

  4. I would like to convey my gratitude for your generosity in support of persons who should have help with that concept. Your special dedication to getting the solution around ended up being really invaluable and have constantly helped professionals just like me to get to their endeavors. Your new valuable guide means a great deal a person like me and somewhat more to my fellow workers. Regards; from all of us.

  5. I wanted to write down a simple note so as to say thanks to you for the awesome solutions you are placing at this website. My incredibly long internet lookup has finally been paid with brilliant concept to exchange with my best friends. I would claim that most of us readers are truly fortunate to live in a magnificent site with so many marvellous individuals with helpful tricks. I feel very much fortunate to have seen the website and look forward to so many more entertaining moments reading here. Thank you once again for all the details.

  6. I simply wanted to make a simple comment to be able to appreciate you for all of the fantastic solutions you are giving out at this site. My prolonged internet investigation has at the end been rewarded with excellent knowledge to write about with my close friends. I ‘d claim that most of us website visitors are undoubtedly lucky to live in a useful site with very many brilliant people with beneficial opinions. I feel quite privileged to have discovered your webpage and look forward to tons of more entertaining minutes reading here. Thank you once again for all the details.

  7. I must show my thanks to the writer for rescuing me from such a predicament. Just after researching through the search engines and getting suggestions which are not powerful, I believed my life was well over. Existing minus the answers to the difficulties you’ve resolved through your main review is a crucial case, as well as those that would have negatively damaged my career if I hadn’t discovered your web site. Your own personal ability and kindness in maneuvering all the stuff was crucial. I’m not sure what I would have done if I hadn’t encountered such a step like this. I can at this time look ahead to my future. Thanks a lot so much for your impressive and effective help. I won’t be reluctant to recommend the website to anybody who will need direction on this issue.

  8. I as well as my pals were actually taking note of the great advice from your web blog and so suddenly came up with a terrible feeling I had not thanked the web blog owner for them. All the young men ended up as a consequence warmed to read them and now have really been taking pleasure in them. Thank you for truly being indeed kind and then for selecting varieties of fabulous issues millions of individuals are really needing to discover. Our own honest regret for not expressing appreciation to you sooner.

  9. I definitely wanted to construct a note to say thanks to you for some of the fantastic points you are showing on this website. My prolonged internet look up has at the end of the day been honored with pleasant concept to write about with my visitors. I would suppose that many of us site visitors actually are very much blessed to live in a decent website with so many brilliant people with valuable hints. I feel very much blessed to have come across your entire webpage and look forward to many more enjoyable times reading here. Thank you once again for a lot of things.

  10. I simply desired to say thanks all over again. I am not sure what I would have implemented without the actual tricks shown by you regarding such theme. This has been a very daunting dilemma for me personally, nevertheless being able to see this expert approach you treated that made me to weep with contentment. Now i am happy for your information and pray you are aware of a powerful job you are always providing educating people through your webpage. I know that you’ve never encountered all of us.

  11. Thanks for all your valuable effort on this site. Debby really likes working on research and it’s simple to grasp why. We all hear all of the compelling form you give both interesting and useful ideas by means of the web site and therefore invigorate participation from other ones about this area of interest plus our princess is starting to learn a lot. Have fun with the remaining portion of the new year. You are always performing a superb job.

  12. Thanks a lot for providing individuals with remarkably splendid chance to read critical reviews from this blog. It’s usually so sweet plus stuffed with amusement for me personally and my office friends to visit your website nearly 3 times every week to study the latest secrets you have. And indeed, I’m also certainly impressed with the very good creative concepts you serve. Certain 3 points in this post are in fact the simplest we have had.

Leave a Reply

Your email address will not be published.