Skip to content

Configure continuing line comments #13274

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

Open
tye-exe opened this issue Apr 5, 2025 · 5 comments
Open

Configure continuing line comments #13274

tye-exe opened this issue Apr 5, 2025 · 5 comments
Labels
C-enhancement Category: Improvements

Comments

@tye-exe
Copy link

tye-exe commented Apr 5, 2025

Issue

I like the change to continuing line comments, as this is useful when writing documentation. However, i often find myself commenting out code and then using the o/O keybinds to create newline after/before the commented code. This is to still be able to reference the older code, and suppress any errors that come from it, whilst rewriting it. And this change drastically disrupts this process, feeling very unintuative to me, as i do not expect comments to be inserted outside of editing documentation.

Part of this is when i am writing documentation i very rarely use the o/O keybinds, more often being in insert mode for extended periods of time, where this feature is greatly appreciated and highly beneficial. Whereas when writing code i spend alot more of my time in normal mode.

Proposed Changes

I'd propose adding a configuration option that toggles whether comments get continued on new lines when they are created with the open_below/open_above actions. After looking at the configuration options, i am not sure where this would be located.

Alternatively, i propose adding two static commands open_below_no_comment/open_above_no_comment.

Remarks

I will be happy to develop and implement either or my two proposals (or any other alternative suggestions) to helix. I am just trying to receive feedback before i make the changes, as i am unsure whether this will be accepted or not.

@tye-exe tye-exe added the C-enhancement Category: Improvements label Apr 5, 2025
@Abdillah
Copy link

Abdillah commented Apr 5, 2025

There also an alternative to provide "comment" and "uncomment" as separate commands. The user can then configure a keymap for ensuring a new line without comment.

@nik-rev
Copy link
Contributor

nik-rev commented Apr 5, 2025

this was tried before in #12447 but rejected because you can already do this:

[keys.normal]
g.O = ["open_above", "delete_word_backward"]
g.o = ["open_below", "delete_word_backward"]
[keys.insert]
A-ret = ["insert_newline", "delete_word_backward"]

it acts basically the same as "insert newline, but don't add comment token"

it won't work if the comment token has spaces in it, but it should work for almost all languages

@tye-exe
Copy link
Author

tye-exe commented Apr 5, 2025

[keys.normal]
g.O = ["open_above", "delete_word_backward"]
g.o = ["open_below", "delete_word_backward"]
[keys.insert]
A-ret = ["insert_newline", "delete_word_backward"]

Would this still work if there was no comment to delete?

@nik-rev
Copy link
Contributor

nik-rev commented Apr 5, 2025

[keys.normal]
g.O = ["open_above", "delete_word_backward"]
g.o = ["open_below", "delete_word_backward"]
[keys.insert]
A-ret = ["insert_newline", "delete_word_backward"]

Would this still work if there was no comment to delete?

it would not, which is a little unfortunate but you have to pay attention (you can always undo the step with u)

i would personally like to have these static commands:

  • insert newline above with no comment
  • add newline with no comment
  • insert newline below with no comment

3 commands that don't need to be bound to anything by default is possibly not too many extra commands??

@tye-exe
Copy link
Author

tye-exe commented Apr 5, 2025

Hmm, that's unfortunate.

it would not, which is a little unfortunate but you have to pay attention (you can always undo the step with u)

The point of making this change would be to make it so that you do not have to pay attention, which is what a good tool should feel like. It shouldn't get in your way.

i would personally like to have these static commands:

insert newline above with no comment
add newline with no comment
insert newline below with no comment

I agree with this completely. I would support a PR making these changes.
I think that it would be better to not modify any existing keybinds, as to reduce user impact, but add in the new option for inserting without comments. That way users can choose whilst not having any existing configurations break.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-enhancement Category: Improvements
Projects
None yet
Development

No branches or pull requests

3 participants