skip to Main Content

How to paste the screenshot from clipboard gracefully in VS Code, VS Code will copy this image when the current specified directory and rename it according to the time

The built-in markdown plugin has a markdown.experimental.copyFiles.destination setting, but there is no documentation explaining how to configure it, and using the’Paste Image ‘plugin for example has no effect

2

Answers


  1. First you need to enable editor.experimental.pasteActions.enabled ("Enable/disable running edits from extensions on paste."). Then you can set markdown.experimental.copyFiles.destination configuration according to its documentation:

    Defines where files copied into a Markdown document should be created. This is a map from globs that match on the Markdown document to destinations.

    The destinations may use the following variables:

    • ${documentFileName} — The full filename of the Markdown document, for example readme.md.
    • ${documentBaseName} — The basename of Markdown document, for example readme.
    • ${documentExtName} — The extension of the Markdown document, for example md.
    • ${documentDirName} — The name of the Markdown document’s parent directory.
    • ${documentWorkspaceFolder} — The workspace folder for the Markdown document, for examples, /Users/me/myProject. This is the same as ${documentDirName} if the file is not part of in a workspace.
    • ${fileName} — The file name of the dropped file, for example image.png.

    For example, to paste any pasted images in the same directory as the markdown file you are pasting into, use:

    "markdown.experimental.copyFiles.destination": {
        "**/*": "${documentDirName}/"
    }
    
    Login or Signup to reply.
  2. Took me a bit of trial and error to figure out how this works. Setting Item="**/*" and Value="images/" will copy a file I paste into a Markdown file into the images/ directory

    enter image description here

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