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

Keep selection after commenting #528

Open
josecastillolema opened this issue Nov 22, 2023 · 4 comments
Open

Keep selection after commenting #528

josecastillolema opened this issue Nov 22, 2023 · 4 comments

Comments

@josecastillolema
Copy link

Is there a way to keep a selection after commenting?

Thanks!

@josecastillolema josecastillolema changed the title Keep selection Keep selection after commenting Nov 22, 2023
@alerque
Copy link
Member

alerque commented Nov 22, 2023

You looking for gv?

@josecastillolema
Copy link
Author

Sorry @alerque I do not follow, could you please elaborate?
Just to clarify what I meant:

  1. Select a text in visual mode
  2. Press <leader>c<space> (NERDCommenterToggle)
  3. Have the selected text commented AND the keep the selection from step 1

@alerque
Copy link
Member

alerque commented Nov 22, 2023

Because there are a variety of possible use cases and starting scenarios, I'm not sure it makes sense to try to bake this into NERDCommenter itself, but VIM already provides the tooling to compose actions like this yourself. gv reselects that last visual mode selection range, so all you need to do is write yourself a map bound to whatever you like that calls the comment function you'd like and then gv at the end. All VIM commands are comparable this way so you can build up whatever combination of actions you want.

@josecastillolema
Copy link
Author

Hi @alerque , thanks for your comment.
Just to document in case anyone it's trying the same setup, have tried:

map <C-/> <plug>NERDCommenterToggle gv<cr>

but presents a erratic behavior.
Anyway, if you maintainers feel that this is not the native way of moving forward let me know and I'll close the issue.
Thanks

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

No branches or pull requests

2 participants