在vim中轻松评论(C ++)代码 [英] Easily comment (C++) code in vim

查看:219
本文介绍了在vim中轻松评论(C ++)代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我看过以下问题:

如何注释掉VIM中的一段Python代码

但这不是似乎为我工作。

But that does not seem to work for me. How do I comment code easily without resorting to plugins/scripts?

推荐答案

您可以使用用于vim的NERD评论者插件,它支持一大堆语言(我确信C ++是其中之一)。使用此安装,要注释/取消注释任何行,请使用< Leader> ci 。要对文本块执行相同操作,请通过输入 visual 模式并使用与上述相同的命令来选择文本。

You can use the NERD commenter plugin for vim, which has support for a whole bunch of languages (I'm sure C++ is one of them). With this installed, to comment/uncomment any line, use <Leader>ci. To do the same for a block of text, select text by entering the visual mode and use the same command as above.

这里还有其他功能,例如注释 n 行在命令前提供一个计数,在注释之前用< Leader> cy ,使用< Leader> c $ 注释到行尾,您可以在链接中阅读。我发现这个插件是非常有用的,是我必须的插件之一。

There are other features in this such as comment n lines by supplying a count before the command, yank before comment with <Leader>cy, comment to end of line with <Leader>c$, and many others, which you can read about in the link. I've found this plugin to be extremely useful and is one of my 'must have' plugins.

这篇关于在vim中轻松评论(C ++)代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆