skip to Main Content

Within the explorer panel of VS Code itself, if I want to copy a file to another directory in the workspace, I can use ctrl+c and ctrl+v, but if I find a file from another application on my computer such as the native File Explorer application, first pressing the shortcut key ctrl+c and then going to the VS Code window and pressing the shortcut key ctrl+v in the Explorer panel, there is no effect.

Note that I’m not talking about copying the contents of the file and pasting into VS Code. I’m talking about copying "the file" as in the notion of the file to the desktop environment.

The workaround is the use the native file explorer, copy the file first, then open the folder opened in VS Code, and finally paste it within the native file explorer. But I find this so troublesome.

Is there an easier way to do this? Does VS Code support such functionality to paste files copied to the clipboard from a different application (not VS Code) and paste into VS Code? Is that functionality hidden behind a setting that I need to change? Or is this possible via an extension?

2

Answers


  1. Vscode does dragging the filename from a native file explorer (at least on Windows) and dropping in vscode’s Explorer where you want it.

    You can also use your OS’s Open With... functionality and then drag the tab of that editor into whichever directory you want.

    Login or Signup to reply.
  2. At the time of this writing, this is not supported… yet!

    Work to implement this is tracked under this GitHub issue: Explorer: allow to paste files from the clipboard into target folder #130036, which is a subtask of a larger issue tracking a larger effort for Better drag and drop / clipboard integration of files across applications #164.

    You can show your support for the issue ticket by giving a thumbs up reaction to the issue. But please don’t make a "me too" comment. "me too" comments generally come off as annoying to repo maintainers because they clutter up discussion and don’t contribute anything of significant value.

    pingren (a contributor to the VS Code repository) tried to implement this and found it to be more complicated than it looks. You can read their explanation of why in their comment there. One of the difficulties stems from itegration with system keybindings and VS Code’s affordance for remapping keys:

    the onPaste event could only be triggered by system paste (cmd+V on macOS). Users could change filesExplorer.paste command to any keybindings. So we need to consider how to merge native paste from clipboard and VSCode explorer paste.

    There’s another feature-request issue (Copy paste files from native explorer to vscode #89862, created before #130036) where isidorn (another VS Code contributor) commented:

    This is a fair feature request however I believe there is a Chrome limtation which is preventing us from achieving this. […]

    As for extensions that might do this, I don’t know of any (but haven’t tried searching intently).

    Other possible workarounds:

    • Try dragging the file from your native file explorer application to the VS Code file explorer panel. This is confirmed to work at least on Windows and Ubuntu.

    • From Mark‘s answer (copied under CC-BY-SA):

      You can also use your OS’s Open With... functionality and then drag the tab of that editor into whichever directory you want.

    • From user103‘s answer (copied under CC-BY-SA), and partially mentioned in the question post already:

      You can choose Add File from File to add a file to your workspace. Or you can use New File from File to create a new file in your workspace and copy the content of the file outside to it.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search