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

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

Open
tyru opened this issue Oct 9, 2010 · 3 comments
Open

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

tyru opened this issue Oct 9, 2010 · 3 comments

Comments

@tyru
Copy link
Owner

tyru commented Oct 9, 2010

Currently gcc (by default, if <Plug>(caw:prefix) is not mapped by user)
is mapped to <Plug>(caw:hatpos:toggle).

call s:map_user('c', 'i:toggle')

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 tyru changed the title More intelligent comment action 'gcc' Mapping: Detect <Plug>(caw:a:...) comment Dec 23, 2015
@tyru
Copy link
Owner Author

tyru commented Dec 23, 2015

Update title and body.

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

@tyru tyru changed the title 'gcc' Mapping: Detect <Plug>(caw:a:...) comment Smarter 'gcc' mapping Mar 18, 2016
@tyru
Copy link
Owner Author

tyru commented Mar 27, 2016

Simplify comment.

@tyru tyru changed the title Smarter 'gcc' mapping Smarter 'gcc' mapping (like Emacs "comment-dwim") Mar 27, 2016
@tyru
Copy link
Owner Author

tyru commented Mar 16, 2020

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?

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

1 participant