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

support standard "ctrl-d" select-next-instance functionality (by whatever key-binding) #11995

Open
lineality opened this issue Nov 4, 2024 · 5 comments
Labels
C-enhancement Category: Improvements

Comments

@lineality
Copy link

Please support the standard "ctrl-d" select-next-instance functionality as is in:

  • google colab
  • lapce
  • atom
  • vsCode
    et al.

The exact key-binding I do not care about at all, but having the ability to hit ~one key to select the next instance of highlighted text is the most useful function of all time. It is the function I most often use in every editor I use (except Helix doesn't have it). Please please please consider supporting it.

I love Helix and hope Helix thrives.

(I looked to see if this request existed, I did not find it; appologies if this is a repeat.)

Go Team Helix!

@lineality lineality added the C-enhancement Category: Improvements label Nov 4, 2024
@TornaxO7
Copy link
Contributor

TornaxO7 commented Nov 4, 2024

You could create a keybinding for that.
Basically, you can follow the following steps:

  1. Select your word
  2. Hit *
  3. Then press n

Example

yeetus
deletus
maximus

and yeet

select, in the first line the prefix yeet, then press * and then n (for the next occurence) and then both yeets are selected.

@lineality
Copy link
Author

You could create a keybinding for that. Basically, you can follow the following steps:

  1. Select your word
  2. Hit *
  3. Then press n

Example

yeetus
deletus
maximus

and yeet

select, in the first line the prefix yeet, then press * and then n (for the next occurence) and then both yeets are selected.

Thank you, TornaxO7 for the tip!
For example, let's say I wanted to change five instances of thinkingcap to thinking_cap,
(and vice versa) how would I use your method?

@ntzm
Copy link

ntzm commented Nov 5, 2024

@lineality enter visual mode with v before pressing n.

So do something like:

Select word to replace:
miw
Save to register:
*
Enter visual mode:
v
Select the next 5 instances:
5n
Collapse each selection to just the cursor:
;
Delete the underscore

@lineality
Copy link
Author

lineality commented Nov 7, 2024

@ntzm and @TornaxO7 Thank you so much for the tips.
With your help I was able to more or less emulate "ctrl+d" (though I still think it would be groovy for helix to add a one-button ctrl+d functionality)

This is working for me (thanks to your tips!):

modal equivalents of 'simple ctrl-d':

(Note: I may not be using the terms 'highlight' and 'select' correctly.)

General Command Elements:

  • esc = NOR = normal mode
  • v = SEL = Select mode? / visual mode? to 1. select manually with cursor, 2. to keep/accumulate selections
  • i = INS = insert mode
  • '*' (shift+8) = add selected text to register

Selection

(Note: 'w' and 'e' seem to be the same)

  • v + cursor moves = manual selection of characters
  • bw = auto selects the whole current word from the beginning
  • e = auto select to the end of the word in NOR(normal) mode (seems the same as w) (hitting 'e' (or 'w') repeatedly moves ahead/down and highlights each next word. in 'v' (SEL) mode it aggregates/keeps the highlights, in 'esc'(NOR) normal mode it just jumps un-highlighting/selecting the last word (but not a multiple cursor),, but not as a multiple-cursor)
  • b = auto selects back to the beginning of the word (hitting 'b' repeatedly moves back/up and highlights each next word) in 'v' (SEL) mode it aggregates/keeps the highlights (but not a multiple cursor), in 'esc'(NOR) normal mode it just jumps un-highlighting/selecting the last word)

Highlight-Next:

n (or esc+n) = jump ahead to highlight the next instance of *-register-saved item
vn = keep-selected (like ctrl+d) with a 2nd (Nth) cursor, and jump ahead

Alternate:

  • You can use 'n'(in NOR mode) to jump ahead to highlight the next instance, then if you want to select that hit 'vn' (and if you don't want to keep the next selected use esc+n).

reset: (?)

  • clicking with your mouse, or moving up to the top of the doc, is the only way I found to reset multiple cursors to one.

@ntzm
Copy link

ntzm commented Nov 8, 2024

You can use , (keep_primary_selection) to keep only one cursor.

e and w are different in because e jumps to the end of the word and w jumps to the start of the next word.

All these are described in the tutor if you haven't done that already, it's a good resource.

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