ChatGPT解决这个技术问题 Extra ChatGPT

How to select all instances of selected region in Sublime Text

Is there a shortcut key or single-step menu option to find and select all instances of a highlighted selection in Sublime Text?

I thought that this was a to the point, clear, complete and specific. It answered exactly what I wanted to know. Thanks for a real question. Have an upvote... :)

t
the Tin Man

On Mac OS you can use: CMD + CTRL + G


I can not remember it. Some suggestion for good mnemotechnic? What g could stand for?
@andi get all of them? :)
There are standard OS X commands for find next (⌘G) and find previous(⌘⇧G) in the Edit->Find menu. But I tend to think of them as get next and get previous so naturally ⌘^G is get all.
@andi gotta select'em all?
@andi "f" -> "find" "g" -> "find next" "g is next to f" "cmd+shift+f" -> "find all" "cmd+ctrl+g" -> "get all" nevemind, that doesn't help
t
the Tin Man

On Windows/Linux press Alt+F3.


just want to put out there that is uses the same case sensitive settings as find or find and replace. I kept changing the class name as well as the instance name. :\
@Mathias I've never understood the practice of using class and instance names that are identical in all but type case. I always feel like either the class name is too specific, or the instance name is too general and not descriptive enough.
You know how hard naming actually is. It might seem like an easy task but I find myself struggeling with good names for both classes and instances a lot. I think the "instance is lowercase class name"-thing kind of makes sense. I mean - it gives you the type of the variable on first glance. The only annoying thing is if you have multiple of TextField. You can't name all of them textfield of course. So I admit that in some cases it's not specific enough (like TextFields) but if you are talking about controllers, I think it makes perfect sense eg articleController = new ArticleController()
So in a way it really depends on the situation, but in general I think that the class name should already be a good description and therefore also fitting for the instance. BUT - obviously this is a question of tast much like: tabs vs spaces ... PS: Dear internet - I do not want to start another tabs vs spaces flame war here ... :)
This doesn't seem to work for me, I highlight a section of code, Ctrl+I to start searching, borders around all search term within highlighted region, then Alt+F3, but it selects all matching terms in the file instead of just the region.
t
the Tin Man

On Windows/Linux press Alt+F3.

This worked for me on Ubuntu. I changed it in my "Key-Bindings:User" to something that I liked better though.


You shouldn't edit the defaults files, as they'll be overwritten on an update. Instead, copy the property to your "Key Bindings - User" file and edit it there, e.g. { "keys": ["ctrl+shift+g"], "command": "find_all_under" }
This is a duplicate of an existing answer, and would be better suited as a comment.
@dbw - I agree with you, but to the best of my knowledge there's no rule on SO that discusses what to do with duplicate answers.
@dbw - It seems that the most appropriate thing to do with duplicate answers such as this one is to downvote them. So -1 from me. See this on meta: meta.stackexchange.com/a/226562/228219
t
the Tin Man

On Mac:

⌘+CTRL+g

However, you can reset any key any way you'd like using "Customize your Sublime Text 2 configuration for awesome coding." for Mac.

On Windows/Linux:

Alt+F3

If anyone has how-tos or articles on this, I'd be more than happy to update.


your answer is useful to me:)
t
the Tin Man

Note: You should not edit the default settings, because they get reset on updates/upgrades. For customization, you should override any setting by using the user bindings.

On Mac:

Sublime Text 2 > Preferences > Key Bindings-Default

Sublime Text 3 > Preferences > Key Bindings

This opens a document that you can edit the keybindings for Sublime.

If you search "ctrl+super+g" you find this:

{ "keys": ["ctrl+super+g"], "command": "find_all_under" },

But don't make changes on default config files, as they are replaced on update & upgrades. Use user key binding files instead @dcryan22
@ilhnctn Right, you shouldn't edit these. You should override them in the user keybindings. I just posted the default binding to show what the key combination was.
Thanks for noticing that @ilhnctn. I've updated my answer.
t
the Tin Man

In the other posts, you have the shortcut keys, but if you want the menu option in every system, just go to Find > Quick Find All, as shown in the image attached.

Also, check the other answers for key binding to do it faster than menu clicking.

https://i.stack.imgur.com/Anuem.png


t
the Tin Man

Even though there are multiple answers, there is an issue using this approach. It selects all the text that matches, not only the whole words like variables.

As per "Sublime Text: Select all instances of a variable and edit variable name" and the answer in "Sublime Text: Select all instances of a variable and edit variable name", we have to start with a empty selection. That is, start using the shortcut Alt+F3 which would help selecting only the whole words.


This is great to know. Alt+F3 without selection -> whole word. With selection -> precise match.