我正在从TextMate切换到MacVim。我应该使用哪个以及为什么? tComment或The NERD Commenter
答案 0 :(得分:10)
我更喜欢在Perl代码中列出NERDCommener的tComment样式。
原件:
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;
我也喜欢tCommenet的默认映射,感觉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
答案 1 :(得分:3)
尝试两者,看看最适合你的是什么
答案 2 :(得分:2)