How to navigate between instances of selected text in Sublime Text 3?

后端 未结 4 2197
自闭症患者
自闭症患者 2020-12-29 07:08

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?

相关标签:
4条回答
  • 2020-12-29 07:46

    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.

    0 讨论(0)
  • 2020-12-29 07:53

    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" },
    
    0 讨论(0)
  • 2020-12-29 08:02

    I also needed to navigate through occurrences of a word in a quicker way than:

    • Ctrl + F
    • Type world to find
    • Press F3 to find next occurrence.

    And I just found this tip:

    • Select occurrence
    • Ctrl+F3 to find next occurrence, or Ctrl+Shift+F3 for the previous one.
    • At this point the occurrence is already the search text, so you can simply use F3 for next one and Shift+F3 for previous, if you need to navigate between more occurrences.

    I hope this also helps you.

    0 讨论(0)
  • 2020-12-29 08:04

    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:

    • Forward [OS X Cmd+G :: Windows F4]
    • Back [OS X Cmd+Shift+G :: Windows Shift+F4]

    Some more here :: http://www.cheatography.com/njovin/cheat-sheets/sublime-text-2-keyboard-shortcuts-windows/

    What am I missing in your question?

    0 讨论(0)
提交回复
热议问题