If I understand you correctly, you want to have one map (in i, n, & v-mode) that either comments the current line or the visual selection. This is what tcomment's <c-_><c-_>
map does now (with the exception that you want to maintain the visual selection). In order to use <c-/>
you have to set g:tcommentMapLeader1 = '' (or some other map, since <c-/>
seems to be the same as <c-_>
as echristopherson pointed out) in vimrc and then define your maps for <c-/>
.
This should work (add these lines to .vimrc):
let g:tcommentMapLeader1 = ''
noremap <silent> <c-/> :TComment<cr>
vnoremap <silent> <c-/> :TCommentMaybeInline<cr>gv
inoremap <silent> <c-/> <c-o>:TComment<cr>
You might have to replace <c-/>
with <c-_>
to make this work. Since you reported that tcomment already worked when typing <c-/><c-/>
, the <c-_>
map should work.
Anyway, I'd also recommend to use the operator maps since those fit better the way vim works. I don't think using a single key is still a good idea though.