简体   繁体   中英

How to search folder of the currently selected file in Open Editors

I have a file open and actively editing. If i hit ctrl-f , it will search the current file. I want to search all files that are in the folder of this currently opened file. Is there a way to do this?

I know i can go to the tree pane, select the parent folder of the file, Shift-Alt-F. the Search window opens and the "files to include" defaults to the selected folder. But this is a lot of work to do. There must be an easier way, or an extension, but ive yet to find anything .

thanks derek

You can do this with an extension I wrote: Find and Transform .

You could make a keybinding like this (in keybindings.json ):

  {
    "key": "ctrl+shift+f",          // whatever keybinding you want
    "command": "runInSearchPanel",
    "args": {
      // "find": "FIXME",
      "filesToInclude": "${relativeFileDirname}",
      "triggerSearch": true
    }
  }

Trigger that keybinding and it will use the parent directory of the currently focused file. With no find value it will use your selected word in the file - or the word at the cursor.

[I am thinking of adding a context menu item for this Search in Folder functionality, let me know if that would be of interest. No keybinding, just a context menu option.]

在文件夹中查找演示

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM