caw.vim
caw.vim copied to clipboard
Smarter 'gcc' mapping (like Emacs "comment-dwim")
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
Update title and body.
Before: More intelligent comment action
After: 'gcc' Mapping: Detect <Plug>(caw:a:...)
comment
Simplify comment.
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?