简体   繁体   English

设置CTRL + /在vim中进行注释和取消注释

[英]Setting CTRL + / for comment and uncomment in vim

I am new to Vim. 我是Vim的新手。 Just started using it. 刚开始使用它。 There is one which seems to be missing in vim which is the easy of commenting and uncommenting code. vim中似乎缺少一种,它易于注释和取消注释代码。 Could anyone tell me how to map the Ctrl + / keys to comment and uncomment code in Vim. 谁能告诉我如何映射Ctrl + /键在Vim中注释和取消注释代码。 I am using NERDCommenter but I am not sure how I could map the commenting commands to CTRL + / 我正在使用NERDCommenter,但不确定如何将注释命令映射到CTRL + /

I want to use the same keys for single line and multi line comment. 我想对单行和多行注释使用相同的键。

Due to the way that the keyboard input is handled internally, various key combinations, especially with Ctrl , unfortunately aren't possible today, even in GVIM. 由于内部处理键盘输入的方式,不幸的是,即使在GVIM中,今天也无法实现各种组合键,尤其是Ctrl键。 This is a known pain point, and the subject of various discussions on vim_dev and the #vim IRC channel. 这是一个已知的痛点,也是有关vim_dev和#vim IRC通道的各种讨论的主题。

With NERD_commenter, either use the default mappings that start with <Leader>c (where <Leader> is \\ by default), or remap as described by :help NERDComMappings . 使用NERD_commenter时,可以使用以<Leader>c开头的默认映射(默认情况下<Leader>\\ ),也可以按照:help NERDComMappings重新映射。

Some people (foremost Paul LeoNerd Evans) want to fix that (even for console Vim in terminals that support this), and have floated various proposals, cp. 有些人(最重要的是Paul LeoNerd Evans)想解决这个问题(甚至对于支持此功能的终端机中的控制台Vim),并提出了各种建议cp。 http://groups.google.com/group/vim_dev/browse_thread/thread/626e83fa4588b32a/bfbcb22f37a8a1f8 http://groups.google.com/group/vim_dev/browse_thread/thread/626e83fa4588b32a/bfbcb22f37a8a1f8

But as of today, no patches or volunteers have yet come forward, though many have expressed a desire to have this in a future Vim 8 major release. 但是到目前为止,还没有补丁或志愿者出现,尽管许多人表示希望在将来的Vim 8主要发行版中使用它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM