This is a VS Code extension that adds a "Paste Relative Path" command. When the contents of the clipboard are a file path, use this command to paste the relative path to that file from the current document.
For example, if you copy the text /foo/alpha/file1.md
onto the clipboard, then open the file /foo/beta/file2.md
and run the Paste Relative Path command, the text ../file1.md
will be inserted.
There is also a "Paste Relative Path as Markdown" command, which pastes a link using Markdown syntax.
If you run the command with text already selected, the selected text becomes a link: for example, foo
would change to \[foo\](../file1.md)
.
If you run the command without any text selected, a new link is inserted and the text is either the title of the target document (if it can be determined) or the filename of the target.
The title of the target document can currently only be guessed if its file extension is .md
or .markdown
and it contains either a YAML metadata block with a title
field, or a top-level markdown heading (eg # Foo
).
(If you never want to use the title for the link text, set the config pasteRelativePath.useTitleForMarkdownLinks
to false
.)
- Add commands to the editor context menu. There is a setting to disable this if you don't like it.
- Add option to disable reading titles of Markdown files.
- Fix excessive percent-encoding when pasting Markdown links
- Add 'Paste Relative Path as Markdown' command
- Refactoring
- Resolve symlinks before calculating relative path
- Initial release
This is available as open source under the terms of the MIT License.