Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

tComment Vs. The NERD Commenter [closed]

Tags:

vim

macvim

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

like image 804
ma11hew28 Avatar asked Jan 17 '11 19:01

ma11hew28


3 Answers

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
like image 101
ISQ Avatar answered Oct 24 '22 13:10

ISQ


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

like image 37
Rafael Vega Avatar answered Oct 24 '22 11:10

Rafael Vega


try both and see what suits you best

like image 20
Robokop Avatar answered Oct 24 '22 13:10

Robokop