caw.vim icon indicating copy to clipboard operation
caw.vim copied to clipboard

Support for motion commands

Open kagbodji opened this issue 6 years ago • 5 comments

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!

kagbodji avatar May 04 '18 15:05 kagbodji

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 avatar May 04 '18 16:05 tyru

@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

AlexMasterov avatar Sep 22 '18 18:09 AlexMasterov

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!

kagbodji avatar Sep 27 '18 17:09 kagbodji

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.

machakann avatar Sep 28 '18 05:09 machakann

ah, it needs vim-operator-user, but very neat :)

tyru avatar Sep 30 '18 21:09 tyru