Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

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

Go to character #12878

Closed
ShiromMakkad opened this issue Feb 15, 2025 · 2 comments · May be fixed by #12888
Closed

Go to character #12878

ShiromMakkad opened this issue Feb 15, 2025 · 2 comments · May be fixed by #12888
Labels
C-enhancement Category: Improvements

Comments

@ShiromMakkad
Copy link

ShiromMakkad commented Feb 15, 2025

This is coming from this post: https://www.reddit.com/r/HelixEditor/comments/1ipjmxx/best_way_to_extend_selection_to_character/

Take this code: principal: EntityUid, #[default(entity_id("Action", "test-action"))] action: EntityUid that's in the middle of a larger line. My cursor is at p and I want to delete the macro.

First, I need to jump to the #. I can do that with f#;. Unlike Vim, I need an extra keystroke to clear the selection before starting a new selection. Next, I need to press vta then repeatedly press Alt-. There's a risk of overshooting, and I don't see a way to undo this, so I opened #12877.

The other option is to use gw, but using it, waiting for the suggestions to come up, and then reading the label is slow (in the same line). Also, gw would land my cursor at the end of action, so that means more keystrokes. For traversing in the same line, I prefer pressing w repeatedly.

I'm proposing a goto_character option inside the goto menu. It will allow you to press two characters to go to unlike f and ts one character. It should also work with Alt-..

Like other goto macros, it won't drag the selection with it unless you're in selection mode. Instead, it will select the two characters. With this, the above sequence becomes (I'm binding goto_character to c) gc#[vgc] d. Personally, I'd actually like to bind it to v since c is taken (I didn't use it for the example since there's another v in there).

Alternatively, you could make a key in normal mode that drags the selection, just like f that selects on two characters. I prefer something in the goto menu it eliminates the keystroke to clear the character when starting at #. Either way, you have to press v at the start of the selection because you might hit something incorrect that matches your two character pattern until #8761 is fixed.

@ShiromMakkad ShiromMakkad added the C-enhancement Category: Improvements label Feb 15, 2025
@nik-rev
Copy link
Contributor

nik-rev commented Feb 16, 2025

So essentially what you are proposing is 2-character alternatives to f, and F (that create a new selection instead of dragging)?

I think that's a good idea. Instead of calling it goto_character (which is misleading since chars have length 1 and this is 2 chars) we could call it find_next_char_pair or something like that. Then in terms of keybindings, unsure. Ideally we pick a keybinding that is a mnemonic and makes sense (e.g. don't put it on <C-w>)

Edit: I think these mappings make sense:

  • L for find_next_char_pair
  • H for find_prev_char_pair

Edit2: Put out a PR for this. #12888

@ShiromMakkad
Copy link
Author

Awesome, thanks!

@helix-editor helix-editor locked and limited conversation to collaborators Feb 17, 2025
@pascalkuthe pascalkuthe converted this issue into discussion #12898 Feb 17, 2025

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
C-enhancement Category: Improvements
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants