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

feat: Alt-Enter inserts newline without continuing comment #12447

Closed

Conversation

nik-rev
Copy link
Contributor

@nik-rev nik-rev commented Jan 7, 2025

The comment functionality is really useful, but often times I just want to make a newline without continuing the current comment. And without needing to disable the feature entirely, just for 1 newline

This PR:

  • Renames insert_newline to insert_newline_continue_comment
  • Adds insert_newline, which does not continue the comment
  • Binds Alt-Enter to insert_newline and Enter to insert_newline_continue_comment

Also added these, but feel free to reject them:

  • Renames open_below and open_above to open_below_continue_comment and open_above_continue_comment
  • Adds open_below and open_above which add a newline below and above, but do not continue the comment
  • Binds go to open_below and o to open_below_continue_comment
  • Binds gO to open_above and O to open_above_continue_comment

Related to #12423


Note: Chose A-ret instead of S-ret because the latter seems to not be supported by Helix. I tested with Kitty and Wezterm

@TornaxO7
Copy link
Contributor

TornaxO7 commented Jan 7, 2025

Hm... I see what you mean, but isn't fine for removing the comment token?

@nik-rev
Copy link
Contributor Author

nik-rev commented Jan 7, 2025

Hm... I see what you mean, but isn't fine for removing the comment token?

could you clarify what you mean by this?

@pascalkuthe
Copy link
Member

Not really a fan of the proliferation of commands and keybindings here.

I think <ret><c-w> is not much worse than <alt-ret> and has the same effect. This is also the solution used in vim (continue comments is even the default there)

@TornaxO7
Copy link
Contributor

TornaxO7 commented Jan 7, 2025

Hm... I see what you mean, but isn't fine for removing the comment token?

could you clarify what you mean by this?

Oh lol, somehow a word despawned or I didn't write it out. I meant <C-w> while in insert mode. In general you can use it in your terminal to remove a whole word.

@nik-rev
Copy link
Contributor Author

nik-rev commented Jan 8, 2025

Ok, that sounds reasonable. I am happy with these keybindings:

[keys.insert]
A-ret = ["insert_newline", "delete_word_backward"]

[keys.normal.g]
O = ["open_above", "delete_word_backward"]
o = ["open_below", "delete_word_backward"]

Which do mostly the same as what we have in the PR. (exception is that if you use them on a line that is not a comment, it will delete the leading tabs that get auto-inserted with tree sitter, but i dont think its a big deal since you would only use these keybindings on lines with comments)

@nik-rev nik-rev closed this Jan 8, 2025
@nik-rev nik-rev deleted the newline-no-continue-comment branch January 8, 2025 13:42
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

Successfully merging this pull request may close these issues.

3 participants