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

Make * also select the word under the cursor #1762

Open
antoyo opened this issue Mar 6, 2022 · 7 comments
Open

Make * also select the word under the cursor #1762

antoyo opened this issue Mar 6, 2022 · 7 comments
Labels
A-helix-term Area: Helix term improvements C-enhancement Category: Improvements

Comments

@antoyo
Copy link
Contributor

antoyo commented Mar 6, 2022

Describe your feature request

I would find it more convenient if * would also select the word under the cursor before doing a search.
The search should also be on word boundary (wrapped with \b).
That's the behavior of vim.

We can keep the current search_selection as it is, perhaps under another shortcut.

@antoyo antoyo added the C-enhancement Category: Improvements label Mar 6, 2022
@antoyo
Copy link
Contributor Author

antoyo commented Mar 6, 2022

Now that I think of it, perhaps we only need to have a command for the <C-s> shortcut in the prompt and to submit the search.
That would allow use to remap * to the following:

[keys.normal]
"*" = ["search", "insert_word", "submit_search"]

What do you think?

This seems more generic and would allow for instance creating a new shortcut to do the same for global search.

However, we'd need a way to wrap the word with \b. Any idea for how we could do this? I guess we could make a command for this, but that doesn't seem generic to me.

Now that I think of it, that would require many commands while issue #1383 would allow something like:

"*" = "@/\b<C-s>\b<CR>"

which seems much simpler.

That wouldn't work as is, though, because the search is incremental.

@kirawi kirawi added the A-helix-term Area: Helix term improvements label Mar 8, 2022
@ttys3
Copy link
Contributor

ttys3 commented Apr 21, 2022

currently * will set register / to current char, which I think is not the most freq case.

it's good to make it default select the word.

@txtyash
Copy link
Contributor

txtyash commented Sep 28, 2022

This is really necessary!

@mitsuhiko
Copy link
Contributor

At the very least I would expect * to actually execute the search. Right now to do what * does in VIM which is a pretty common operation you need to do something like alt+o followed by * and then n.

@mitsuhiko
Copy link
Contributor

mitsuhiko commented Oct 11, 2022

I ended up with this binding BTW that mostly emulates what I'm currently used to from vim:

[keys.normal]
"*" = ["move_prev_word_start", "move_next_word_end", "search_selection", "search_next"]

@ubitux
Copy link

ubitux commented Feb 12, 2023

For the record, # and * in vim (respectively backward and forward search of symbol under the cursor) is incredibly useful to read code as it helps tracking usages of a given symbol. Here is a demo of a typical symbol tracking workflow in nvim using # and *:

vim-star-sharp.mp4

I'm guessing #5702 will also help here.

@milesfrain
Copy link

Looks like this is being tackled in #6046

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

No branches or pull requests

7 participants