caw.vim
caw.vim copied to clipboard
Support for motion commands
Is it possible to support motion commands when commenting? Specifically, I wish to do 5gcc
to toggle comments on the next five lines. This is a feature I sorely miss from NerdCommenter My current alternative is to visually select the 5 lines, then gcc
to comment them out; this is much slower however.
Thanks!
This is surely missing thing,
but if you turn on let g:caw_operator_keymappings = 1
and install kana/vim-operator-user,
you can do gcc5j
to comment out next 5 lines.
Do you want to do 5gcc
? or gcc5j
is enough?
@tyru, same issue. 5gcc. I'm currently using this technique: (same thing, but native?)
nnoremap <silent> <Plug>(caw:range:toggle) :<C-u>call <SID>cawRangeToggle()<CR>
function! s:cawRangeToggle() abort
if v:count > 1
let winView = winsaveview()
execute "normal V". (v:count - 1) ."j\<Plug>(caw:hatpos:toggle)"
call winrestview(winView)
else
execute "normal \<Plug>(caw:hatpos:toggle)"
endif
endfunction
g:caw_operator_keymappings = 1
Hi @tyru, sorry for the late reply. I was not aware of this setting, I think it works for now. I do prefer 5gcc
however, because it's slightly faster; using gcc5j
, it seems a simple line comment now requires gcc0
. For now, I think Alex's solution works best for me.
Thanks!
Another solution here:
nmap gcc <Plug>(caw:hatpos:toggle:operator)_
xmap gcc <Plug>(caw:hatpos:toggle:operator)
This is .
command repeatable. Note you need vim-operator-user
.
ah, it needs vim-operator-user, but very neat :)