How to select all instances of selected region in Sublime Text - sublimetext

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

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

On Windows/Linux press Alt+F3.

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.

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.

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" },

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.

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.

Related

Sublime Text - show open files on the left

Is there a way to show the files that are open in SublimeText on the left of the screen, in a simple list?
I'd simply like the open files to appear on the left in a clickable way like this
file1.txt
file2.css
file3.htm
etc
is that possible?
Go to the "View" menu and choose "Side Bar", then "Show Open Files"
Right click on open file in editor...
Click on Reveal in Side Bar option, it will sync the open file with side bar
Ctrl+K+B will reveal the 'Side bar', with open file information. It is really worth using projects, they are really simple and provides for easy folder/project/file switching.
I also strongly reccomend going to preferences>Key Bindings - Default through the menus, and looking at all the functionality and keyboard shortcuts. Also 'preferences>Settings - Defualt`, shows you all of the configurable options (there are a lot). These are basically 'must dos' for getting full goodness out of Sublime.
If you want to do it only using keyboard, Command + Shift + P and select View: Toggle Open Files in Side Bar
Here's the key binding to run this shortcut using the keyboard:
[
{ "keys": ["super+shift+j"], "command": "reveal_in_side_bar" },
]

Xcode4, I use to be able to select some text and right click and search on that text in xcode3?

In Xcode 3 I use to be able to select some text, right click and search for that text.
However in Xcode 4 this seems to have disappeared ?
Is there a quick alternative instead ?
EDIT
I'd select some source code and it would find all occurences in the rest of the source code.
Select text; cmd-E
Then Shift-cmd-F; return
Boom.
Select your text, hit command-E ("use selection for find") and command-G to iterate through results.
Find in Workspace appears to be fundamentally broken in Xcode 4.
Someone else posted a workaround: toggle the Assistant Editor button to enable the menu item. However it still is not available for text in the debug output area.
Search in workspace (you can read the keyboard abbreviation in Edit -> Find -> find in workspace
You can always try some keyboard shortcuts combination once your text is selected:
command+C
command+F (if you want to
search in the current file, otherwise
shift+command+F to look into the
whole project)
command+V
Then you can iterate through the results with command+G to go forward or shift+command+G to go backward.
Hope this helps.

How can I find and replace inside a selection in Xcode?

In Xcode < 4, you could hold the "option" key, and the "Replace All" button would change to "Replace in Selection". As of Xcode 4, this does nothing. Anyone know if there's a new way to do it, or is it bug filing time?
This appears to be working again now, at least in Xcode 4.4.1.
When the find/replace bar appears at the top of the editor, holding down the option key on the keyboard causes "Replace in Selection" to appear in lieu of "Replace All."
I'm glad, because this was an ANNOYING omission.
Another workaround:
In Xcode, select the text, press copy
In a terminal session:
pbpaste|sed 's/SOURCETEXT/NEWTEXT/g'|pbcopy
Return to Xcode window, press paste
Since the original should still be selected, it will just be replaced. You could probably build a simple shell script to do this.
Doug
An few images to supplement the chosen answer:
And holding down Option:
See also
Find/Replace in Xcode using Regular Expressions
Seems like missing functionality. You should file a bug report.
I'm upset that they took out this functionality, as I used it constantly, but here's my workaround. Copy your selected text from Xcode4 to TextEdit or some other word processor, do the find and replace there, and then copy the results back into Xcode.
It's not sexy but it's worth it if you do a lot of these "find and replace on my selection", and you leave the word processor open in Spaces as you work.
They should add "my selection" as an alternative to "workspace" and "my scope".
There is another way only replace the matches you find, rather than just this one or all of them.
I suggest you save a copy first, just in case....
In Find and Replace, Show Find Options (you can do this by pressing the magnifying glass).
Press Preview.
Uncheck all the ones you don't want replacing.
Press Replace
Hope that helps, it did me.
Not ideal, but not too bad:
Do a find and replace in workspace (cmd-opt-shift-f) enter your desired find/replace
Enter your desired search term and hit return
Select the range of replacements from the list of matches on the left
Hit replace (not replace all)
To replace text in a selection using Xcode 9
Press Option-Command-F to bring up the find/replace box.
Enter the search and replace string. Changing the search string will lose any existing selection, so..
Make your selection (again). (If you don't do this, the selection will be the first search string found only)
Hold down the key and "Replace All" will change to "Replace Selection", then click it.
Once you understand that you make your selection AFTER you have entered the search string, then this is not that clumbersome and works fine.
I find alt-command-f easier for local find and replace (4.3) and then working around your selection.
EthenA.Wilson asked in a comment to the OP a couple of days ago:
"Is there a way to do this in Xcode 5?"
For the benefit of those who, like me, had been searching for it, here's how:
After you put your Find and Replace terms in the bars at the top left-hand side of the editor page, select the text you want to search in, then look at the top right-hand side (same bar). You'll see where it says "All", right next to "Replace." Now press the Option key. "All" will change to "All in Selection." Click it, and you're done. Could be a bit more intuitive, but the functionality is there in Xcode 5.
Naturally, good idea to take a snapshot before you click!
HTH!
Not sure which feature prior to Xcode 4 you're referring to, but the shortcut Command+Shift+E gives you "Use Selection for Replace". If you're talking about "Find and Replace in Workspace" (Command+Option+Shift+F), then what you need to do is run your find and then hold down "Shift" or "Command" on the selections shown and then hit "Replace".

Textmate tab and de-tab selected block

Recently switched to Textmate on Mac for coding. On PC when ever I want to tab in or out a block of code I just highlight and press tab or shift+tab to move it in our out. It's very useful when you are adding an extra loop or conditional statement to a block of code to keep everything tidy and neatly indented.
On Textmate however when I try this it just replaces my selected text with a tab. So is there a way to do tab and de-tab lines of code in textmate?
Indent: Alt+Tab
Un-Indent: Shift+Alt+Tab
the hotkey is command-left bracket to move left and command-right bracket to move right
(the buttons next to 'p')
heres a link to more hotkeys and such
http://projects.serenity.de/textmate/tutorials/basics/
You can use Shift+Tab to decrease indent; You just need to make and assign a macro. You can reuse this technique to accomplish a great many things.
Enter some text, and intend them, this is mostly for feedback.
Click the Record Macro Button
Use ⇧+⌥+⇥ (aka; Shift + Option + Tab) to decrease the indentation.
Click the record button to stop recording the macro.
Use the Edit menu or ⌃+⌘+M to save your macro;
Saving will prompt you to create a new bundle*, or add your macro to an existing bundle.
Add a Key Equivalent by clicking in the field and pressing ⇧+⇥
Your bundle-macro should look like the one below, simply Save and you're done! TextMate will now decrease indent on ⇧+⇥
*: (as noted by u/PatrickT) Sadly the create new bundle functionality has not yet been implemented, and you must choose to add to an existing bundle. You can still create a bundle via Bundles -> Edit Bundles then Command + N.
As an alternative, you can change the keybindings, see Link
Here is what I did:
Install Link
Go to File -> Open -> User Key Bindings, this will create/edit ~/Libary/KeyBindings/DefaultKeyBinding.dict
Add a binding, for the action enter shiftRight: (indent) manually (this is a TextMate specific action and not in the pre-populated actions list)
Choose a shortcut, I used cmd+alt+right
Do the same for the action shiftLeft: (un-indent, I used cmd+alt+left)
Save and then restart TextMate
I used a shortcut with arrow keys as my right hand is already on the arrow keys when I am selecting multiple lines, so this is a good fit.
The reason why I did it was because I have a german keyboard and alt+tab/alt+shift+tab don't work for me since I am using Witch for app-switching using these exact shortcuts.
EDIT: cmd+alt+left/right don't work when you have multiple tabs open, as they are used for navigate to next or previous tab in TextMate... seems this cannot be changed or overridden (I tried Setting Shortcut Keys in Textmate). Looking for an alternative shortcut now.

Textmate: remap Escape for word completion

In the Textmate code-editor I use the Escape-key, for word completion, alot.
Is there a way to bind another key-shortcut to its functionality ?
(ps: my CAPSLOCK is already CTRL)
A much better way to do this (and this applies to all Mac apps in general) is to
Open System Preferences > Keyboard & Mouse > Keyboard shortcuts
Click the + sign at the bottom
Choose TextMate from the application menu
Type the exact name of the menu command for next completion and previous completion
Now type the shortcut you want to use and click the Add button
To remap the esc key you have to copy
/Applications/TextMate.app/Contents/Resources/KeyBindings.dict
to
~/Library/Application Support/TextMate/KeyBindings.dict
and then edit it, preferably using TextMate :) as Property List Editor messes up the codes.
Look for nextCompletion and previousCompletion and replace their values with whatever suits your needs best. For example, you could replace \033 (code for esc) to \t (->|).

Resources