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

New shortcut to select all matching text #5448

Closed
exalted opened this issue Jun 16, 2022 · 22 comments
Closed

New shortcut to select all matching text #5448

exalted opened this issue Jun 16, 2022 · 22 comments
Labels
enhancement [core label]

Comments

@exalted
Copy link
Contributor

exalted commented Jun 16, 2022

VSCode calls this "select all occurrences of find match", and the gist is that I'd like to be able to select a piece of text (usually a word, a function name, a variable name, etc.) hit the keyboard combo (e.g., Cmd-Ctrl-g) and have all occurrences being selected.

Right now the workaround I am using is to select the text and keep Cmd-d pressed until it selects all matching text.

@exalted exalted added enhancement [core label] triage Maintainer needs to classify the issue labels Jun 16, 2022
@exalted exalted changed the title New shortcut to select all matching New shortcut to select all matching text Jun 16, 2022
@JosephTLyons JosephTLyons removed the triage Maintainer needs to classify the issue label Jun 16, 2022
@iamnbutler
Copy link
Member

Want

@JosephTLyons
Copy link
Collaborator

This would be a really nice way to do replaces in a single buffer - just grab all text and change it all at once.

@SomeoneToIgnore
Copy link
Contributor

image

Intellij provides somewhat enhanced functionality that allows to not only do "select all matches" thing, but also to add/remove such selections one by one, while searching.

@as-cii as-cii assigned as-cii and unassigned as-cii Feb 16, 2023
@porsager
Copy link

This is the only thing keeping me with Sublime. Is there any way to know if this is considered and if there's a plan to add it?

@ryanwinchester
Copy link

Was just about to main Zed with some fixes I've been waiting for in v0.90.

However, I'm 10 minutes in and I don't know if I can live without this. I use it quite a bit.

@probablykasper
Copy link

I think VSCode's Cmd-Shift-L shortcut would be nice, instead of involving Ctrl

SomeoneToIgnore referenced this issue Jul 14, 2023
Closes https://github.com/zed-industries/community/issues/75
Closes https://github.com/zed-industries/community/issues/1749

The PR 

* changes keybindings for `Editor && mode == auto_height` context:
before, `alt-enter` and `alt-shift-enter` added new lines in such
editors, including the one from buffer search.

New bindings are the same as in `Editor && mode == full` context.

* adds `search::SelectAllMatches` action and binds it to `Alt + Enter`
by default, to select all matches of a buffer search

The behavior mimics VSCode: we do not move the screen even if all
selections are out of the visible range (Cmd+G will navigate there) and
allow reselecting the results from both pane and search field, as long
as the search is not dismissed.

Release Notes:

- Added `search::SelectAllMatches` (`Alt + Enter` default) action to
place carets and select all buffer search results
([#75](https://github.com/zed-industries/community/issues/75),
[#1749](https://github.com/zed-industries/community/issues/1749)).
@SomeoneToIgnore

This comment was marked as outdated.

@ryanwinchester
Copy link

ryanwinchester commented Jul 14, 2023

@SomeoneToIgnore Will this work in the Editor context, not just the BufferSearchBar mentioned in #6208, since I see they were referenced to each other and closed in the same version? 🙏

i.e. would work alongside this section's editor::selectNext as something like editor::selectAll?

  // Bindings from VS Code
  {
    "context": "Editor",
    "bindings": {
      "cmd-[": "editor::Outdent",
      "cmd-]": "editor::Indent",
      "cmd-alt-up": "editor::AddSelectionAbove",
      "cmd-ctrl-p": "editor::AddSelectionAbove",
      "cmd-alt-down": "editor::AddSelectionBelow",
      "cmd-ctrl-n": "editor::AddSelectionBelow",
      "cmd-d": [
        "editor::SelectNext",
        {
          "replace_newest": false
        }
      ],
      "ctrl-cmd-d": [
        "editor::SelectPrevious",
        {
          "replace_newest": false
        }
      ],
      "cmd-k cmd-d": [
        "editor::SelectNext",
        {
          "replace_newest": true
        }
      ],
      "cmd-k ctrl-cmd-d": [
        "editor::SelectPrevious",
        {
          "replace_newest": true
        }
      ],
     // ...
}

@porsager
Copy link

Wooo.. awesome.. Can't wait to try it out.. Is there a date for 0.96?

@SomeoneToIgnore
Copy link
Contributor

SomeoneToIgnore commented Jul 14, 2023

The feature pretty much mimics VSCode behavior at this point: as long as the buffer search input is open, whether the caret is inside the editor or inside the search input, the action will focus to the editor and select + place the caret to all matches.

Screen is not moved, the selection number stays the same with selectNext and reverse continuing the search, if invoked after selectAll (all but one carets will be removed again in this case).

So far, the feature does not touch the project search (with multiple editors), only a singleton buffers are affected.

The configuration by default was placed in the BufferSearchBar context, alongside the other search-related items:

{
    "context": "BufferSearchBar",
    "bindings": {
      "escape": "buffer_search::Dismiss",
      "tab": "buffer_search::FocusEditor",
      "enter": "search::SelectNextMatch",
      "shift-enter": "search::SelectPrevMatch",
      "alt-enter": "search::SelectAllMatches"
    }
  },

and duplicated for Pane context.

Also, there's now a button in the search bar itself:
image


The release is supposed to happen in ~2 weeks for Stable and one week for Preview, somewhere around Wednesday.

@ryanwinchester
Copy link

ryanwinchester commented Jul 14, 2023

as long as the buffer search input is open

@SomeoneToIgnore that is not cmd-shift-L (or ctrl-cmd-g in Sublime)

It should be like cmd-d except instead of Next it's All. There is no search buffer when doing this. It's happening to selected text in the editor.

I think #6208 was incorrectly associated with this one

@SomeoneToIgnore
Copy link
Contributor

SomeoneToIgnore commented Jul 14, 2023

That is all very confusing, looks I was wrong indeed.
Let's reopen this issue, and keep my original message as a workaround: you can now select a text, press Cmd+F and Alt + Enter to achieve similar effect with one extra shortcut.

@ryanwinchester
Copy link

ryanwinchester commented Jul 14, 2023

@SomeoneToIgnore cmd-shift-L in VS Code example

Screen.Recording.2023-07-14.at.5.06.45.PM.mov

@ryanwinchester
Copy link

@JosephTLyons this was re-opened but it's not in #5393 anymore (just sayin 😅)

@JosephTLyons
Copy link
Collaborator

@JosephTLyons this was re-opened but it's not in #5393 anymore (just sayin 😅)

Was it in #5393 recently? It looks like the issue at the end of the list has 40 upvotes and this one has 25, so I dont think it has had enough votes to be there, at least not for a long time.

@ryanwinchester
Copy link

ryanwinchester commented Jul 15, 2023

I could be wrong, I just saw this on this issue's timeline and assumed it used to be in there.

Screenshot 2023-07-15 at 12 32 47 AM

Maybe it had been grouped with other issue(s)... Sorry about the ping

@JosephTLyons
Copy link
Collaborator

JosephTLyons commented Jul 15, 2023

Wooo.. awesome.. Can't wait to try it out.. Is there a date for 0.96?

We ship a new minor version every Wednesday (unless its a crazy holiday time). Right now, stable is at v0.94. So v0.96 should go out the Wednesday after next (July 26th).

Edit: Missed Kirill's comment explaining it, my bad. 😅

@JosephTLyons
Copy link
Collaborator

I could be wrong, I just saw this on this issue's timeline and assumed it used to be in there.

Screenshot 2023-07-15 at 12 32 47 AM

Maybe it had been grouped with other issue(s)... Sorry about the ping

Yeah you're right, I think it was on there a long time ago, when we first started getting upvotes and all issues were kind of in the top. It got booted off sometime after that as other issues were upvoted past it.

@ryanwinchester
Copy link

Every Wednesday I open up Zed and check the update and every Wednesday I sad.

@JosephTLyons
Copy link
Collaborator

JosephTLyons commented Sep 20, 2023

Every Wednesday I open up Zed and check the update and every Wednesday I sad.

No reason to be sad today @ryanwinchester, it will be going out today in v0.105.0-pre :)

@JosephTLyons
Copy link
Collaborator

Ok, so this is officially released, but we made a mistake and put in the wrong binding. We used cmd-shift-d, which by default is duplicate line, so we're going to put out a patch to make it cmd-shift-l. Hang tight.

@JosephTLyons
Copy link
Collaborator

We also have a crash when the selection is empty - this will be fixed in the same patch.

@JosephTLyons JosephTLyons transferred this issue from zed-industries/community Jan 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement [core label]
Projects
None yet
Development

No branches or pull requests

8 participants