How to create Shortcut to open a specific file only?
-
I started maintaining work notes in a text document, pre Evernote/OneNote days, say in a file named worknotes.txt. I add code, tips, tricks, queries, urls etc to this file with some comments.
How do I create a shortcut in Notepad++? I tried creating a macro but the macro doesn’t work. I created it by menu option Macro - Start Recording - File - Open - type the file name etc and then Stop Recording. To test my macro, I selected menu option Macro - Playback but it didn’t work.
To verify that I am recording the macro, I created other simple macros like find/replace certain string OR insert a single quote to the beginning & end of the lines in a file and all these macros run properly.
Any thoughts/tips/pointers?
Thanks.
-
Why don’t you just leave the file open all the time? It sounds like a valuable file. :-)
You could use the Explorer plugin and create a Favorite of this file. Then it can be made to be visible as an entry on a panel and double-clicking opens it.
You could create a batch file that runs Notepad++ with this file’s path as an argument, and then create a Run menu entry to execute the batch file, thus causing the running instance of Notepad++ to open the file.
I’m sure there are other ways as well. Probably NppExec plugin and Scripting plugins could certainly do it.
Macros, as you’ve noticed, are mainly for “editing data” operations, not things like opening specific files.
-
@Alan-Kilborn said in How to create Shortcut to open a specific file only?:
You could create a batch file that runs Notepad++ with this file’s path as an argument, and then create a Run menu entry to execute the batch file
Don’t even need it as a batch file:
- Run>Run:
"$(NPP_FULL_FILE_PATH)" "c:\path\to\file.txt"
, Save…- as documented here,
$(NPP_FULL_FILE_PATH)
is the full drive, folder, and executable for the active instance ofnotepad.exe
; the quotes are needed if there are spaces in Notepad++'s path. - in case it’s not obvious, replace
"c:\path\to\file.txt"
with the correct path to your file; if there are spaces in the filename, it must have the quotes around it, which is why I included the quotes in the example.
- as documented here,
- Name it
Open Useful File
or similar, assign keyboard shortcut if desired, OK - Run… (to run it immediately) or Cancel (if you don’t need to open it this instant)
Now the Run menu will contain Open Useful File, and that menu entry (and keyboard shortcut) will quickly open the desired file. And
%AppData%\Notepad++\shortcuts.xml
will contain a line like<Command name="Open Useful File" Ctrl="no" Alt="no" Shift="no" Key="0">"$(NPP_FULL_FILE_PATH)" "c:\path\to\file.txt"</Command>
- Run>Run:
-
@PeterJones said in How to create Shortcut to open a specific file only?:
Don’t even need it as a batch file
An advantage of the batch file is that, when Notepad++ isn’t running, you can start it via the batch (e.g. pinned on the task bar), and make sure your favorite file is gonna be there when the UI presents itself. :-)
-
@PeterJones Perfect - I was exactly looking for this. I had seen something in TextPad and used it frequently and was struggling to mirror it in Notepad++. Thanks a lot again!!!
-
@Alan-Kilborn Thanks for your reply. Leaving the file open has been my workaround so far. Yes, its my go to file and I would be lost without it :-)
I will keep in mind your suggestions & tricks and will definitely come in handy.