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

Smarter 'gcc' mapping (like Emacs "comment-dwim")

Open tyru opened this issue 13 years ago • 3 comments

Currently gcc (by default, if <Plug>(caw:prefix) is not mapped by user) is mapped to <Plug>(caw:hatpos:toggle). https://github.com/tyru/caw.vim/blob/037fb8d67dcdbdb1ecc9765856dcc6718ae332e9/plugin/caw.vim#L139

But I want gcc mapping to be smarter: Detect which comment action should current comment under cursor be handled by (except jump and input):

  • hatpos
  • zeropos
  • dollarpos
  • wrap
  • box

And dispatch invoked method to detected action:

<Plug>(caw:{action}:{method})

Reference

About Emacs comment plugin (Japanese)

tyru avatar Oct 09 '10 13:10 tyru

Update title and body.

Before: More intelligent comment action After: 'gcc' Mapping: Detect <Plug>(caw:a:...) comment

tyru avatar Dec 23 '15 14:12 tyru

Simplify comment.

tyru avatar Mar 27 '16 16:03 tyru

dwim toggle

mode() ==# 'n':
  current cursor is Comment:
    detect comment type and uncomment
visualmode() ==# 'v':
  current range is all included within Coment:
    detect comment type and uncomment
  else:
    wrap comment (characterwise)
visualmode() ==# "\<C-v>":
  current range is all included within Coment:
    detect comment type and uncomment
  else:
    wrap comment (characterwise)

TODO: customizable?

tyru avatar Mar 16 '20 15:03 tyru