Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for motion commands #80

Open
kagbodji opened this issue May 4, 2018 · 5 comments
Open

Support for motion commands #80

kagbodji opened this issue May 4, 2018 · 5 comments

Comments

@kagbodji
Copy link

kagbodji commented May 4, 2018

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!

@tyru
Copy link
Owner

tyru commented May 4, 2018

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?

@AlexMasterov
Copy link

@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

@kagbodji
Copy link
Author

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!

@machakann
Copy link
Contributor

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.

@tyru
Copy link
Owner

tyru commented Sep 30, 2018

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants