It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center




7年前关闭。





我正在从TextMate切换到MacVim。我应该使用哪个?为什么? tCommentThe NERD Commenter

最佳答案

至少在Perl代码中,我比NERDCommenter更喜欢tComment的样式。

原版的:

 my $foo;
 if ($foo) {
     $foo = 1;
     $bar = 1;
 }
 return $bar;


t评论:

 my $foo;
 # if ($foo) {
 #     $foo = 1;
 #     $bar = 1;
 # }
 return $bar;


NERD评论员:

 my $foo;
 #if ($foo) {
     #$foo = 1;
     #$bar = 1;
 #}
 return $bar;


我也喜欢tComment的默认映射,这对于Vim来说更原生。基本的是:

gc{motion}   :: Toggle comments
gcc          :: Toggle comment for the current line
gC{motion}   :: Comment region
gCc          :: Comment the current line


我在vimrc中添加了一些映射,现在我很高兴:

 " tComment extra mappings:
 " yank visual before toggle comment
 vmap gy ygvgc
 " yank and past visual before toggle comment
 vmap gyy ygvgc'>gp'.
 " yank line before toggle comment
 nmap gy yygcc
 " yank and paste line before toggle comment and remember position
 " it works both in normal and insert mode
 " Use :t-1 instead of yyP to preserve registers
 nmap gyy mz:t-1<cr>gCc`zmz
 imap gyy <esc>:t-1<cr>gCcgi


还有一个一致性映射:gcc切换注释行,而gc切换注释视觉,所以让它更加一致:

 vmap gcc gc

关于vim - tComment与NERD评论员,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/4716810/

10-12 16:42