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

Granular commenting #4009

Open
txtyash opened this issue Sep 28, 2022 · 14 comments
Open

Granular commenting #4009

txtyash opened this issue Sep 28, 2022 · 14 comments
Labels
A-helix-term Area: Helix term improvements C-enhancement Category: Improvements

Comments

@txtyash
Copy link
Contributor

txtyash commented Sep 28, 2022

Selections in line can't be commented. The entire line gets commented. Granular control with C-c would fix this.

@txtyash txtyash added the C-enhancement Category: Improvements label Sep 28, 2022
@dead10ck dead10ck added E-easy Call for participation: Experience needed to fix: Easy / not much A-helix-term Area: Helix term improvements E-good-first-issue Call for participation: Issues suitable for new contributors labels Sep 28, 2022
@dead10ck
Copy link
Member

Would this just insert a comment marker to the left of the cursor?

@txtyash
Copy link
Contributor Author

txtyash commented Sep 28, 2022

There's some plugin in lunarvim that comments text using gc<movement> or visual selection and gc
So here,

This part|[cursor]is

|(cursor) & [] is the selection.
Running C-c here should comment the word "cursor":

This part #cursor is

I'm not saying that this is a clever binding. This is just the idea. If planned, then better bindings could be implemented.

@the-mikedavis the-mikedavis changed the title Granular C-o Granular C-c Sep 28, 2022
@CptPotato
Copy link
Contributor

I actually like the current behavior. If this is implemented I'd prefer it as a separate command.

@txtyash
Copy link
Contributor Author

txtyash commented Sep 29, 2022

I actually like the current behavior. If this is implemented I'd prefer it as a separate command.

Yes, the current behavior is short and fast. I don't want this feature to slow down or interfere with the current implementation.

@txtyash txtyash changed the title Granular C-c Granular commenting Sep 29, 2022
@filipdutescu
Copy link
Contributor

I think that for languages which support it, an option could be added to comment only the selection (from your example it appears as though the comment is from #cursor to the end of the line).

So for

This part|[cursor]is

|(cursor) & [] is the selection.

you'd have:

  1. Comment from selection to end of the line
This part #cursor is
  1. Comment only the selection
This part /*cursor*/ is

@AK-10
Copy link

AK-10 commented Nov 27, 2022

How about implementing a toggle_block_comments without touching the toggle_comments like vscode?

@AK-10
Copy link

AK-10 commented Nov 27, 2022

I'm trying implement the toggle_block_comments command

@gabydd
Copy link
Member

gabydd commented Nov 27, 2022

I actually have mostly implemented that if you want to take a look: #4718

@gabydd
Copy link
Member

gabydd commented Nov 27, 2022

I would say it's pretty much fully implemented I just need to add tests and add it to the docs

@AK-10
Copy link

AK-10 commented Nov 29, 2022

@gabydd
Oh, looks pretty good!
But I think it behaves a little differently than toggle

I think vscode's Toggle Block Comment behaves as toggle

2022-11-30_00-19-59.mp4

@gabydd
Copy link
Member

gabydd commented Nov 29, 2022

Yeah at this moment the surrounding tokens need to be inside the selection, but i think I should be able to get it to search past whitespace surrounding a selection for comment tokens

@pascalkuthe pascalkuthe mentioned this issue Nov 23, 2023
8 tasks
@cotneit
Copy link
Contributor

cotneit commented Feb 29, 2024

Looks like this can be closed now that #4718 is merged?

<space>-C - block comment selection
mac + Ctrl-c - select around block comment and uncomment

Works like a charm, thanks a ton @gabydd!

@gabydd
Copy link
Member

gabydd commented Feb 29, 2024

We might want to have <space>-C be granular even if there isn't a block comment token for the language so you can use that to comment in the middle of a line

@pascalkuthe
Copy link
Member

That sounds reasonably useful to me but there is no way we find this issue. @gabydd could you make an issue that describes that specific subtasks and close this one. I think the main concerns here have been addressed and I usually feel that followup work is better of in its own issues

@pascalkuthe pascalkuthe removed E-easy Call for participation: Experience needed to fix: Easy / not much E-good-first-issue Call for participation: Issues suitable for new contributors labels Apr 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-helix-term Area: Helix term improvements C-enhancement Category: Improvements
Projects
None yet
Development

No branches or pull requests

8 participants