maskeerr
maskeerr

Reputation: 109

How to create Shortcut to open a specific file only in Notepad++ v 7.8.2

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.

I have been using TextPad where I created a shortcut to always open this file by pressing Ctrl+1. But I can no longer use TextPad and am forced to use Notepad++ (Notepad++ v 7.8.2).

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.

Upvotes: 3

Views: 1027

Answers (2)

help-info.de
help-info.de

Reputation: 7260

Instead of a Macro you may want to use Run from the main menu to open your file and add a shortcut for this as shown in the screenshot below.

enter image description here


Update: Steps for adding shortcut

From the main menu goto Run > Run or press the F5 key. Copy the following (previously adapted) call into the text box and SAVE

"$(NPP_FULL_FILE_PATH)" "d:\_temp\my-file.txt"
  • $(NPP_FULL_FILE_PATH) is the full drive, folder, and executable for the active instance of notepad.exe; the quotes are needed if there are spaces in Notepad++'s path.
  • replace "d:\_temp\my-file.txt" with the correct path to your file; if there are spaces in the filename, it must have the quotes around it.

In the next dialog name it Open My File or similar, assign keyboard shortcut e.g Ctrl+F12 click OK and Run to run it immediately or Cancel.

enter image description here

Now the Run menu will contain Open My File, and that menu entry (and keyboard shortcut) will quickly open the desired file.

enter image description here

And %AppData%\Notepad++\shortcuts.xml will contain lines like this:

<UserDefinedCommands>
    <Command name="Get PHP help" Ctrl="no" Alt="yes" Shift="no" Key="112">https://www.php.net/$(CURRENT_WORD)</Command>
    <Command name="Wikipedia Search" Ctrl="no" Alt="yes" Shift="no" Key="114">https://en.wikipedia.org/wiki/Special:Search?search=$(CURRENT_WORD)</Command>
    <Command name="Open my File" Ctrl="no" Alt="yes" Shift="yes" Key="120">&quot;C:\Program Files\Notepad++\notepad++.exe&quot;</Command>
</UserDefinedCommands>

Upvotes: 3

Toto
Toto

Reputation: 91415

Another way to go is to open once the file in Notepad++ and never close it, just save the changes. Then, when you close Notepad++ and reopen it sometimes later, the file is allways present in Notepad++.

For this to work you have to enable Remember current session for next launch:

Settings > Preferences > Backup > Remember current session for next launch

Upvotes: 1

Related Questions