Sublime Forum

Find in selection keyboard shortcut

#1

Apologies is this has been asked, but I haven’t found it anywhere.

What is the keyboard shortcut (on OS X) to toggle Find in Selection with sublimeText 3 beta (or even SublimeText2 which should be the same).

In ST2, when I selected a couple of lines, the Find in Selection option was toggled on by default. This behaviour does not happen in ST3 beta. I understand it’s beta and might not have been implemented yet, but I am looking for the keyboard shortcut to toggle it on so I don’t have to click on the little icon each time.

thanks.

1 Like

[Solved] Keyboard shortcut - Toggle wrap and highlight matches in find dialog
#2

is it possible to bind a toggle shortcut/hotkey, e.g. Alt+S for “in selection” button in Replace dialog?

0 Likes

#3

Add the following to your user key bindings file:

[code]{ “keys”: “alt+s”], “command”: “toggle_in_selection”, “context”:

		{ "key": "setting.is_widget", "operator": "equal", "operand": true }
	]
}[/code]

This works for me in ST3; haven’t tested in ST2.

5 Likes

#4

Tested on sublime 2 : Work’s for me.

Thank’s!

0 Likes

#5

The code above is missing some characters. In Preferences > Key Bindings, add:
[
{ “keys”: [“alt+s”], “command”: “toggle_in_selection”, “context”: { “key”: “setting.is_widget”, “operator”: “equal”, “operand”: true } }
]

To use this in osx to find and replace:
Select the text you want to find and replace in.
Hit command-F to bring up the find dialog.
Enter the text you want to search for.
Hit alt-s to select just the hits that are in the selected text.
Hit alt-return to select for editing.
Now you can backspace to delete or start typing to replace, with a cursor in the place of all found strings within the selected text.

4 Likes

#6

Thank you x 27 for giving the exact key binding, and the usage! That alt-return trick is insanely powerful!!

0 Likes

#7

This solution has some formatting problems when added to the shortcut keymap file ( and instead of ", and missing [ and ] around the context). I’ve updated it for the current version of Sublime Text.

{ "keys": ["alt+s"], "command": "toggle_in_selection", "context":[{ "key": "setting.is_widget", "operator": "equal", "operand": true }]}

If this is the only shortcut in your keymap file, it should look like this:

[ { "keys": ["alt+s"], "command": "toggle_in_selection", "context":[{ "key": "setting.is_widget", "operator": "equal", "operand": true }]} ]

If you are entering it into your keymap file and you have other shortcuts in the file, unless you’re adding it as the last entry, it should end in a comma ,:

{ "keys": ["alt+s"], "command": "toggle_in_selection", "context":[{ "key": "setting.is_widget", "operator": "equal", "operand": true }]},

1 Like

Find in selection behavior