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

Allow find-next without pressing enter #1150

Open
Timmmm opened this issue Aug 13, 2018 · 16 comments · May be fixed by #1159
Open

Allow find-next without pressing enter #1150

Timmmm opened this issue Aug 13, 2018 · 16 comments · May be fixed by #1159

Comments

@Timmmm
Copy link

Timmmm commented Aug 13, 2018

Currently the find behaviour is:

  1. Type ctrl-F
  2. Type your search string
  3. Press enter to find the first match
  4. Press Ctrl-N to find the next match.

Modern text editors (VSCode, etc.) use Ctrl-G for find-next so you can just do:

  1. Type ctrl-F
  2. Type your search string.
  3. Press ctrl-G to find the first match, and subsequent matches.

This is quite a bit nicer. It would be good if micro worked the same way.

Edit: Apparently the default bindings are now fixed in stone so as a compromise the plan is to bind ctrl-F to find and find-next, i.e.

  1. Press ctrl-F
  2. Type your search string.
  3. Press ctrl-F to find the first match and subsequent matches.
@ensilon
Copy link

ensilon commented Aug 21, 2018

You can bind CtrlG to FindNext in bindings.json, but I think the real benefit would be eliminating "step 3" in the current behavior.

My ideal solution would be CtrlF to start searching, then CtrlF again to find the next match (so 2 steps). I've got it working in my copy, but I had to butcher HandleSearchEvent() to make it work.

@supbish
Copy link

supbish commented Aug 22, 2018

Totally agree with the above.

One of the best features of micro, in my opinion, is that it doesn't rely on modes... a mode for writing, another mode for reading / moving around, another mode for selecting stuff, etc, etc.

This is in line with most other modern editors, except for those that run in a terminal. This is what really sets micro apart. In that spirit, I think suggestions like this and #941 -- anything that eliminates mode-like behavior -- should be given serious consideration.

Ideally, "find next" should work at any time, including in the middle of a search as suggested above, or while not searching at all.

@ensilon
Copy link

ensilon commented Aug 22, 2018

This line could be skipped with a config option. When disabled, you can search up/down on the previous term without starting search mode, retyping your serarch term and hitting enter

https://github.com/zyedidia/micro/blob/master/cmd/micro/search.go#L49

@supbish
Copy link

supbish commented Aug 22, 2018

I'm not even sure why it would need to be a config option... if someone doesn't want the behavior, they can just not hit the search next key, right?

I'll play with it later today and see about adding it to #1159.

@Timmmm, zyedidia has explicitly stated (elsewhere on issue tracker) that the default keys will remain the defaults. Can we change the title and wording of this ticket to just address the behavior change, and take out the part about the keybind?

@Timmmm Timmmm changed the title Bind ctrl-G to find next Allow find-next without pressing enter Aug 23, 2018
supbish pushed a commit to supbish/micro that referenced this issue Aug 24, 2018
Also fixes part of zyedidia#941 (can scroll; can't select yet)
@supbish supbish linked a pull request Aug 24, 2018 that will close this issue
@supbish
Copy link

supbish commented Aug 24, 2018

Added this to the search-goodies branch of my fork.
Please try it out and let me know if you find any issues.
👍

@ensilon
Copy link

ensilon commented Aug 27, 2018

This is great. It's still intuitive, but can be much more efficient. Haven't seen any issues.

supbish pushed a commit to supbish/micro that referenced this issue Aug 28, 2018
Also fixes part of zyedidia#941 (can scroll; can't select yet)
@ensilon
Copy link

ensilon commented Aug 29, 2018

An additional thought for search-goodies:

It's pretty easy to have this message (search.go:43) linger indefinitely, since you can stop searching without calling ExitSearch(). It's also an incorrect message for anyone who has re-bound next/previous search.
My only thought is removing it altogether, but that's not great for first-time users. Any ideas?

@supbish
Copy link

supbish commented Aug 31, 2018

Yeah, not sure what to do with that. It might be nice if it appeared where that "show binding, open help" message appears. Looks like there's a major refactor going on now in another branch, gonna wait on that before moving on any PRs.

@AlexWayfer
Copy link

I was searching for a shortcut how to jump to next find result and found this stale issue. 🙃

I agree that hitting Enter is more intuitive for such fresh editor. Esc can be used to exit from find functionality.

Anyway, thank you for Ctrl N.

@alexdelorenzo
Copy link

Ran into this issue and agree with others about a different solution to skip through search results.

@brndd
Copy link

brndd commented Jul 14, 2022

I just want to thank the issue creator for describing the current behaviour. This issue is the first result on Google for "micro editor find" and I end up coming back to it every now and then to remind myself how to actually get to the next result when pressing Enter does nothing.

@jonas-frey
Copy link

jonas-frey commented Sep 5, 2022

I'm confused by the claim in the original report that "Modern text editors (VSCode, etc.) use Ctrl-G". Don't they use F3 and Shift-F3? At least my VSCode does that and looking at settings.json that doesn't seem to be a custom configuration.

Wouldn't it make sense to add F3 and Shift-F3 as shortcuts for find next/previous?

In any case I agree that the present behaviour is unintuitive.

@Timmmm
Copy link
Author

Timmmm commented Sep 5, 2022

Traditionally Ctrl-G is the shortcut on Mac (and Linux maybe?) and F3 is the shortcut on Windows, but Ctrl-G is clearly better so lots of Windows programs have started using it instead of F3 (e.g. Chrome).

@jonas-frey
Copy link

Just as a data point: gnome programs on linux seem to use ctrl+g, kde programs use f3 (they use ctrl+g for "goto line").

@ensilon
Copy link

ensilon commented Sep 22, 2022

@zyedidia if this were to change, would you prefer it to be hidden behind a settings flag? IE searchmode: traditional / modal / ??

@jayarmstrong
Copy link

Just as a data point: gnome programs on linux seem to use ctrl+g, kde programs use f3 (they use ctrl+g for "goto line").

I believe F3 has also been the standard "find next" in all browsers and all Microsoft apps for like 20 years. At least, I've been using it that long. Libreoffice (on KDE) has F3 bound to an autotext feature but after launching the CTRL+F search function, F3 repeats the search.

In terms of improved function, thoughts:

  1. In any browser, I can hit F3 on a tab I've never searched on (never launched the search function with CTRL + F) and it will conveniently, instantly repeat my last search query, with the text highlighted and ready to be replaced if I start typing a new query. So that's nice.
  2. Firefox offers the "search as you type" function described above as a config option. I believe it was on by default for years. This can be an awesome time saver but probably gets in the way of some workflows.
  3. A SHIFTed version of the shortcut to search for previous, as suggested above, would be excellent!

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 a pull request may close this issue.

8 participants