helix
helix copied to clipboard
Granular commenting
Selections in line can't be commented. The entire line gets commented. Granular control with C-c
would fix this.
Would this just insert a comment marker to the left of the cursor?
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.
I actually like the current behavior. If this is implemented I'd prefer it as a separate command.
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.
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:
- Comment from selection to end of the line
This part #cursor is
- Comment only the selection
This part /*cursor*/ is
How about implementing a toggle_block_comments
without touching the toggle_comments
like vscode?
I'm trying implement the toggle_block_comments command
I actually have mostly implemented that if you want to take a look: #4718
I would say it's pretty much fully implemented I just need to add tests and add it to the docs
@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
https://user-images.githubusercontent.com/27846333/204569530-bb167b9b-e314-4bc4-8ffd-6c0bb677c407.mp4
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
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!
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
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