skip to Main Content

I’m looking for a way to fold all results in a VSCode search editor. (It’s clear how to do this in the search explorer.)

I can easily fold individual results with cmd+opt+[ but I want to fold all of the results. I’d actually like to be able to have that be the default.

Editor Search Results

2

Answers


  1. Chosen as BEST ANSWER

    I found the cmd+k, cmd+0 will fold all up to the first line, but then I can open enough to see what I need. Not ideal, but useable.


  2. You can fold all the results by doing this:

    1. Select all Ctrl+A
    2. Command Palette: Create Manual Folding Range From Selection

    That Manual Folding Range command has a default keybinding: Ctrl+K Ctrl+,

    You could put those two commands into a macro if you wanted, see the macro extension multi-command.


    I don’t think there is any way to have the Search Editor default to all folded – unless you put however you open that into the macro as well.

    Doing that using multi-command, make this keybinding:

      {
        "key": "ctrl+w",      // whatever keybinding you want
        "command": "extension.multiCommand.execute",
        "args": {
          "interval": 500,   // you need some delay to open the editor first
          "sequence": [
            "search.action.openInEditor",
            "editor.action.selectAll",
            "editor.createFoldingRangeFromSelection"
          ]
        },
        "when": "hasSearchResult && searchViewletFocus"
      }
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search