notepad++textpad

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.


Solution

  • 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"
    

    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>