t评论与。书呆子评论者

发布于 2024-10-12 14:28:44 字数 231 浏览 3 评论 0原文

我正在从 TextMate 切换到 MacVim。我应该使用哪个,为什么? tComment书呆子评论者

I'm switching from TextMate to MacVim. Which should I use and why? tComment or The NERD Commenter

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

梦纸 2024-10-19 14:28:44

与 NERDCommenter 相比,我更喜欢 tComment 的风格,至少在 Perl 代码中是这样。

原文:

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

tComment:

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

NERDCommenter:

 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

I like style of tComment more than NERDCommenter, at least in Perl code.

Original:

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

tComment:

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

NERDCommenter:

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

I also like default mappings of tComment that feel more native for Vim. The basic are:

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

I have added a few more mappings in vimrc and now I'm fully happy:

 " 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

And one more mapping for consistency: gcc toggle comment line but gc toggle comment visual, so let's make it more consistent:

 vmap gcc gc
墟烟 2024-10-19 14:28:44

我更喜欢评论(我都尝试过)。查看 http://vimsomnia.blogspot.com/2010/11/tcomment -vim-plugin.html

I like tcomment a lot more (I tried both). Check out http://vimsomnia.blogspot.com/2010/11/tcomment-vim-plugin.html

不羁少年 2024-10-19 14:28:44

两者都尝试一下,看看哪一个最适合您

try both and see what suits you best

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文