Notepad3 icon indicating copy to clipboard operation
Notepad3 copied to clipboard

Feature request: Add relative path syntax for file URLs

Open ThomasHeinrichSchmidt opened this issue 3 years ago • 0 comments

It is convenient and helpful to be able to use a reference to a file in Notepad3 like this file:///c:/Users/Thomas%20H.%20Schmidt/Documents/GitHub/README.md that actually allows to open (or edit) the file, see #3138. Since a recent Notepad3 release there is also a keyboard shortcut (Ctrl+F10) to convert a path string "c:\Users\Thomas H. Schmidt\Documents\GitHub\README.md" to the URL format above. The current file:// uses an absolute path which is sometimes annoying when moving the target file somewhere else. It would be more convenient if Notepad3 was able to handle a file URL using a relative path, starting from the (working) directory where the currently edited file was loaded from.

Say I had opened "c:\Users\Thomas H. Schmidt\Documents\GitHub\README.md" and wanted to add a picture located in "c:\Users\Thomas H. Schmidt\Documents\GitHub\README-picture.jpg". It is easy to paste the file path and then use Ctrl+F10 to add the required file URL file:///c:/Users/Thomas%20H.%20Schmidt/Documents/GitHub/README-picture.jpg to the README file. But what if I move all the files to some other place, e.g. to my Dropbox or an USB stick to take them with me? In this case I would have no luck when trying to look at the picture.

So using a relative path URL would be the solution here. If I am currently editing "c:\Users\Thomas H. Schmidt\Documents\GitHub\README.md" I could use file://./README-picture.jpg to refer to the picture in the same directory. I am not sure though if this (file://./name) is the correct format for the relative URL according to the lenghty discussion in File Uri Scheme and Relative Files.

So my feature request goes like this.

  1. Accept a relative file URL (file://./name) as a hyperlink in Notepad3 documents, using the directory of the currently open file as base URL.
  2. Edit / Convert / File System Path to URL (Ctrl+F10) should convert to a relative file URL if the file has the same base URL as the currently open file. Pressing Ctrl+F10 twice could convert to an absolute file URL as it is done now.

ThomasHeinrichSchmidt avatar Feb 04 '22 15:02 ThomasHeinrichSchmidt