Reputation: 17495
Sublime Text 3 highlights all instances of currently selected text. Is there any shortcut to navigate cursor to the next / previous instance (copy) of selected text?
So far, I've only managed to find out some information about adding more instances to current selection (expanding it) with Ctrl+D, skipping current instance (Ctrl+K, Ctrl+D) and deselecting it (Ctrl+U), which actually is a soft undo, not a real command.
I can use Ctrl+D to go to next instance of selected text and Ctrl+U to undo. But, since these shortcuts operates on selection, this is not, what I'm looking for.
Actually, I'm asking, is there any way to have this as simple as pressing Alt+Right to go to the next instance or Alt+Left to go to previous.
If this is not solved by default, then what commands should be tied to user-defined keyboard shortcuts?
Upvotes: 19
Views: 7068
Reputation: 81
I also needed to navigate through occurrences of a word in a quicker way than:
And I just found this tip:
I hope this also helps you.
Upvotes: 6
Reputation: 375
I'm on a mac, and this has sort of already been mentioned, but it doesn't require altering the hotkey menu and works well enough for me.
cmd+K keeps your highlight but deselects it
cmd+D expands your selection (now empty thanks to cmd+k) by including the next occurrence
highlight a string (one that recurs)
while holding cmd -> press K, then press D
alternating back and forth as many times as necessary.
Each time D is alternated to, your highlight and selection jump to only the next occurrence.
Upvotes: 1
Reputation: 462
Yes, all you need to do is edit your key bindings (Sublime Text -> Preferences -> Key Bindings User) for "find_under". Copy & paste this into your bindings and set your keys (defaults are "alt+super+g" and shift+alt+super+g)
{ "keys": ["alt+super+g"], "command": "find_under" },
{ "keys": ["shift+alt+super+g"], "command": "find_under_prev" },
Upvotes: 20
Reputation: 5232
I may be misunderstanding your question but what you are asking seems pretty simple and I wonder if that means you might mean something else. Anyway here's an answer that I hope is what you are looking for.
First, ensure that you have the following set to true in your preferences:
// If true, the selected text will be copied into the find panel when it's
// shown.
// On OS X, this value is overridden in the platform specific settings, so
// you'll need to place this line in your user settings to override it.
"find_selected_text": true,
Select the string you are interested in.
Search in current file [OS X Cmd+F :: Windows Ctrl+F]
Now you can step through the matches:
Some more here :: http://www.cheatography.com/njovin/cheat-sheets/sublime-text-2-keyboard-shortcuts-windows/
What am I missing in your question?
Upvotes: 4