skip to Main Content

Does Visual Studio Code have a built-in function or if there is a plugin that can open all the files I give it at once (as a single action)?

Occasionally I have this requirement where I get a list of file paths and I would like to open all of them in VS Code. Sometimes I create a small script that does that (just calls "code.exe" multiple times), but I’m wondering if perhaps there is a simpler way.

2

Answers


  1. If you run code --help, you’ll see "Usage: code [options][paths...]".

    So just run code <file path 1> <file path 2> <file path 3> <...> in whatever shell of your choice. Make sure to use shell-appropriate quoting if any of the file paths have spaces in them. And you can use relative paths relative to the current working directory of the shell.

    If you already have a VS Code window open, doing so will open those files in the existing window. If you want to open them in a new VS Code window, use the -n (also aliased as --new-window) flag.

    Note also that the File > Open mechanism supports opening multiple files at the same time. You’ll have to use whatever keyboard modifiers are used by your platform (OS)’s native File Explorer application, but usually, it’s holding ctrl/cmd to add a single item to the selection, and holding shift to add a range of consecutive items to the selection.

    Login or Signup to reply.
  2. With the extension File Group v1.2.0 you can use the content of the active editor as file paths and load all the files or first make a selection (multi cursor).

    If the file paths are not absolute you can add variables to construct an absolute path using the file path of the editor file.

    From the Command Palette or editor context menu you can open the selected file paths or all.

    • File Group: Open Files in Active Column
    • File Group: Open Files in Split Column
    • File Group: Open Files in Side Column
    • File Group: Open Files in Column 1
    • File Group: ….
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search