pandith padaya
pandith padaya

Reputation: 1963

vscode navigate search editor using keyboard only

Is there any way to navigate the search editor (whole workspace search) using only cursor keys in vscode ? I'm talking about the whole workspace search and not just the find/replace search.This is the editor I'm talking about

Upvotes: 9

Views: 2001

Answers (1)

soulshined
soulshined

Reputation: 10572

The new search editor thankfully has ported over most of the shortcut commands you have grown to know, but for brevity, this answer will include only the default keybinds with respective command id.

The when expression most commonly associated with these keybinds, should you want to alter them, are :

inSearchEditor

hasSearchResult

searchInputBoxFocus

Searching

Context Lines

  • Toggle context lines : toggleSearchEditorContextLines ALT + L

    Will show n lines before or after search result, for context

  • Reduce context line quantity : decreaseSearchEditorContextLines ALT + -
  • Increase context line quantity : increaseSearchEditorContextLines ALT + =

Query Details

  • Toggle Query Details : workbench.action.search.toggleQueryDetails

    This will toggle the include/exclude file input boxes

Settings

  • Toggle Match Case : toggleSearchCaseSensitive ALT + C
  • Toggle Regex : toggleSearchEditorRegex ALT + R
  • Toggle Word Match : toggleSearchEditorWholeWord ALT + W

Navigation

Luckily, because the search editor is effectively an 'editor', you can continue to use all the keybinds that you are used to. So, in order to jump straight to the editor, you can use whatever your keybind is to jump to an editor group, default is: CTRL + 1 (commandId: workbench.action.focusFirstEditorGroup)

Navigating matches

  • Go to next match : search.action.focusNextSearchResult F4
  • Go to previous match : search.action.focusPreviousSearchResult SHIFT + F4
  • Select all matches : selectAllSearchEditorMatches CTRL + SHIFT + L

Results

  • Deleting result block : workbench.action.searchEditor.deleteResultBlock CTRL + SHIFT + BACKSPACE

    This deletes a block of results from the editor

    For example, in the picture below, if my cursor is anywhere in the 'convert.js' result block the entire convert.js matches would be removed. You can undo this with CTRL + Z

  • Go To Definition (effectively go to file)

    • You can peek with ALT + F12 when your cursor is anywhere on the file name
    • You can assign a keyboard shortcut to follow links for the commandId: editor.action.openLink for when your cursor is on the file name
    • You can go directly to the file & line number of the search result using F12 while your cursor is anywhere on that result

Navigate Back to Input Box

  • Focus Search Input Box From Results: search.action.focusQueryEditorWidget ESCAPE

Searching within Search Editor

As noted, the search editor is effectively an editor, so you can resume using CTRL + F (find) or CTRL + H (find/replace) to narrow down results even more, and the keybinds set for those are maintained as used elsewhere.

search editor

Miscellaneous

  • Search again: rerunSearchEditorSearch CTRL + SHIFT + R

    Perhaps you deleted too many result blocks

Otherwise, while your cursor is actively in the editor (results), you have the freedom to use most of your keybinds per normal, including collapsing/folding, jumping, copying, moving to editor groups etc

Upvotes: 12

Related Questions