18

In Settings/Preferences, Notepad++ has an option on the MISC. tab under 'Clickable Link Settings' to the right, to Enable to open links found in the edited files. It underlines them and opens them on double-click. I've tried it with the file:/// protocol and it works, but it actually executes them according to whatever file-association I have set in Windows.

Is there a way, a protocol, or a way to "make" a (local) protocol, such that Notepad++ opens any kind of files (any extension), from these links in the document, in Notepad++ itself? (ie in another tab)

n611x007
  • 6,566
  • 15
  • 67
  • 91

4 Answers4

8

file:// is an intrinsic protocol of Windows, so if you want to ignore the "whatever file-association [is] set in Windows," i'd suggest you use a dedicated protocol, say npp://. Then add this to your registry (using the corresponding path on your system):

Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\NPP]
@="URL: NotePad++ Protocol"
"URL Protocol"=""

[HKEY_CLASSES_ROOT\NPP\DefaultIcon] @=""C:\Program Files\Notepad++\notepad++.exe""

[HKEY_CLASSES_ROOT\NPP\shell]

[HKEY_CLASSES_ROOT\NPP\shell\open]

[HKEY_CLASSES_ROOT\NPP\shell\open\command] @=""C:\Program Files\Notepad++\notepad++.exe" "%1""

C.B.
  • 226
4

The given answer did not work for my Windows 7 Pro system. The parameter %1 was never (correctly) provided to NotePad++ and it started with an empty new file.

However, instead I started a Batch file through @=c:\soft\start-notepad.bat "%1". In this Batch file I stripped off the NPP:/// prefix from %1 and replaced / with \ inside of %1. From this Batch file the start of NotePad++ with the modified parameter %1 does work perfectly. Here is the short Batch file code:

start-notepad.bat

SET note=insert here the path to notepad++.exe
SET para1=%~1
SETLOCAL ENABLEDELAYEDEXPANSION 
SET para1=!para1:NPP:///=!
SET para1=!para1:/=\!
SET para1=!para1:%%20= !
"%note%" "%para1%"

Spaces and non-ASCII characters need to be encoded in Notepad++ with e.g. %20 for spaces, otherwise the hyperlinking of link NPP:///c:/path/file name.txt will stop after file.

Yay295
  • 263
Luke
  • 41
0

Later versions of Notepad++ have added this ability directly. No URI syntax is necessary; just the filename itself. For example, the document you're editing contains:

for details, see ../other/file.txt

Position the cursor within the file path, right-click, and select "Open File". Notepad++ opens the file.

Don't know when they added this, but v8.6.5 has it.

-1

In Notepad++ v8.3.3 (64bit, Win 11) I am able to open file URLs in notepad++ with one slight modification. The clicked file opens as a new tab in notepad++. For some reason, I need to write:

file:///C:/Me/Documents/My%20File.txt

Note the extra slash after file://.

No other changes made