Monday, April 8, 2013

Notepad++: Launch Firefox, Chrome, IE to your heart's content

Somehow I lost my ability in Notepad++ to open a file in a web browser. I couldn't figure out how to get it back, so I turned to the internet and ran across a solution for people having difficultly setting it up with Google Chrome. I ended up just modifying their solution:



This post on super user (stack exchange) got me started, then I put together how to add Firefox, Chrome, and IE.
http://superuser.com/questions/306736/notepadis-there-a-way-to-fix-the-fact-that-i-cant-run-chrome-from-the-run-me

Shortcuts.xml

Notepad++ uses a "shortcuts.xml" file to store shortcut information. You'll have to poke around, but it's located in your AppData folder, here is where I found mine:
Win7: C:\Users\jmj\AppData\Roaming\Notepad++\

  • It's important to note that this file acts like a registry setting. When Notepad++ is started, it loads those settings into memory, then when it's closed it saves them back to the settings.xml file. This makes it so that you can't edit the shortcuts.xml file in Notepad++ itself because when you close the application it will over-write your changes to the file!
  • Unfortunately the best way to avoid this is to keep NPP closed and edit the file in (gasp!) notepad.exe

You place the commands in the < UserDefinedCommands > section, I've provided that section from my shortcuts.xml file below:
<UserDefinedCommands>
<Command name="Launch in Chrome"  Ctrl="yes" Alt="yes" Shift="yes" Key="82">%LocalAppData%\Google\Chrome\Application\Chrome.exe                       &quot;$(FULL_CURRENT_PATH)&quot;</Command>
<Command name="Launch in FireFox" Ctrl="yes" Alt="yes" Shift="yes" Key="83">&quot;C:\Program Files (x86)\Mozilla Firefox\firefox.exe&quot;    &quot;$(FULL_CURRENT_PATH)&quot;</Command>
<Command name="Launch in IE"      Ctrl="yes" Alt="yes" Shift="yes" Key="84">&quot;C:\Program Files (x86)\Internet Explorer\iexplore.exe&quot; &quot;$(FULL_CURRENT_PATH)&quot;</Command>
</UserDefinedCommands>

  • I copied the "Launch in Chrome" directly from the superuser.com website, then modified it for the remaining calls. 
  • I tried to line up the attributes above so that you can easily read them 
  • You can use the Shortcut Mapper to change the shortcut calls after you have these loading correctly (I haven't bothered yet) 
  • I had to use &quot; to handle spaces in the path (i.e. "C:\Program Files (x86)\Mozilla..") 
  • $(FULL_CURRENT_PATH) refers to the html file you are editting in NPP (ex: jasonjeromeresume.html from the screenshot) 

There are other commands available, read about them in the npp docs:
http://npp-community.tuxfamily.org/documentation/notepad-user-manual/commands

That's it!