I'd like to run a HTML page so I configured the Execute / F5 command as following:

chrome.exe http://localhost:8080/$(FILE_NAME)

It works when the HTML file is located in the root of my Workspace (because my HTTP Web server is set up to do so). But it doesn't work when the file is in a subfolder.

Is there a predefined variable (i.e. $(RELATIVE_PATH)) that can be used to get the file path relative to the Workspace directory?

Thank you by advance for your help.

| improve this question | | | | |
  • 3
    Does Run -> Launch in Chrome not help you? – Burgi May 3 '16 at 12:44
  • 4
    If you are using PHP, you could use http://localhost:8080/redirect.php?file=/$(FULL_CURRENT_PATH) where redirect.php takes off the excessive part. See the article Configuring Notepad++ to run php on localhost. – harrymc May 11 '16 at 11:56
  • 1
    A similar answer would be to use a .bat file to do the string manipulation and call Chrome. Simple to do if you are interested. – harrymc May 11 '16 at 14:52
  • @Supersharp Ctrl+Shift+Alt+R – undo May 12 '16 at 17:46

As of the current version of Notepad++ 6.9.1, the problem with the files in sub-folders path in a web-server has not been fixed yet. The only variable for files path is $(FULL_CURRENT_PATH).

Check: Configuring Notepad++ to run php on localhost.

Maybe this issue will be fixed in the future releases of Notepad++.

| improve this answer | | | | |

Instead of using Chrome directly, you could use a .bat file.

Below is one version of such a .bat file that should be executed in Notepadd++ like this :

"path\to\file.bat" "$(FULL_CURRENT_PATH)"

For Windows, where the document root is in C:\inetpub\wwwroot, the .bat file is :

@echo off
set "param=%~1"
set "url=http://localhost/%param:C:\inetpub\wwwroot\=%"
start "" chrome.exe "%url%"

The general DOS syntax used above for replacing strings in a variable is :


where in our case replacement-string is empty.

This simple .bat file can easily be improved to accept the string C:\inetpub\wwwroot\ as second parameter, and more.

The batch file may cause a black DOS window to appear momentarily, to disappear immediately once Chrome is launched. If it is still too annoying, see this answer.

| improve this answer | | | | |

Python Solution

With Np++ plugins even miracles can be achieved. I wrote a simple Np++ Python Script that achieves exactly this functionality. This solution only requires Notepad++ and the PythonScript plugin.

  1. Install Python Script from Plugins > Plugin Manager
  2. Plugins > Python Script > New Script
  3. Name it "OpenInBrowser.py" (for example) and paste the script: http://pastebin.com/wS4jThcp
  4. In the script, remember to configure your browserExeFullPath, browserUrl and your webpage's rootDir (under which the toplevel index.html would be located).
  5. Plugins > Python Script > Configuration and add your user script to the Menu (left hand list)
  6. Restart Notepad++, Settings > Shortcut Mapper > Plugin commands and map your script to a key, for instance F9. Now pressing that key will open your active document in the browser. No external solutions required.
| improve this answer | | | | |
  • I wasn't able to install the "Python Script" plugin on NPP 6.9.1. – Supersharp May 12 '16 at 9:45
  • What exactly was the problem? I had no issue installing it on 6.9.1 with the Plugin Manager - just checked. Alternatively, you can try installing it manually from npppythonscript.sourceforge.net/download.shtml – pKami May 12 '16 at 9:59
  • 1
    I failed 4 times during download. I won't follow this solution because I don't want to install yet another interpreter (already hold JVM, CLR, Node, Windows' shell...) but I upvoted because it could be a preffered solution for Pyhton users. – Supersharp May 12 '16 at 14:11

Node.js Solution

Based on @harrymc's first comment, I ported the PHP workaround to my Node server.

1° In Notepad++:

Change the <Command> content in the file shortcuts.xml (you can find it under the folder %appdata%/Notepad++), for example:

chrome http://localhost:8080/npp?path=$(FULL_CURRENT_PATH) 

2° In Node.js:

Add a route in the server script (server.js) to handle HTTP GET request:

//redirection for Notepad++
app.get( '/npp', function ( req, res ) 
    res.redirect( req.query.path.substr( __dirname.length + 8 ) )
} )


  • app is my Express component (app = express()),
  • +8 is needed because my web pages are located in a subfolder /public/.
| improve this answer | | | | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.