Closed soerenwolfers closed 5 years ago
If you care about that "immediately" constraint, you're going to have to implement your own custom map that uses reltime()
or something to figure out if the correct amount of time has elapsed.
@tpope Could you give me a hint at how to figure out, using the code you already wrote, the size of the current comment block (0 for current line is not commented, 1 for current line is commented but has no commented neighbors, >1 current line is commented and has commented neighbors)?
I think I have the rest ready (though it is kind of ugly, since it requires sacrificing another key for a new binding, here +
)
nmap ' :call MyUncomment()
nmap + :call MyUncomment2()
namp +' :call MyUncomment3()
function! MyUncomment()
let n = sizeofcommentblock()
if n<2
call <Plug>CommentaryLine
else
call feedkeys("+")
endif
endfunction
function! MyUncomment2() " No more ' was pressed -> uncomment line
call <Plug>CommentaryLine
endfunction
function ! MyUncomment3() " Another press of ' -> uncomment block
call <Plug>Commentary<Plug>Commentary
endfunction
Can I use vim-commentary to create a normal mode map, let's say to
'
, that does:'
is pressed again within a time limit (set timeout
)'
is not pressed again within a time limit (or any other key is pressed)