Mike
Mike

Reputation: 2391

Notepad++: Adding a new shortcut for an existing command

I want to make "Ctrl+G" to open the find dialogue, just as Ctrl+F" (so both shortcuts open the same "find dialogue").

I know I can modify the existing shortcuts of commands through "macro > modify shortcut", but it allows changing the shortcut only, not the "Name" of the command (shaded).

Upvotes: 5

Views: 11165

Answers (1)

Lars Fischer
Lars Fischer

Reputation: 10129

Here is how you can add a second keybinding to the find dialog. Notepad++ does not offers this out of the box. We can only assign one keybinding.
We need a way to add a second find dialog. One way I can think of is by the very useful npp_exec plugin. It offers to create small automation-scripts and we can add these scripts to the menu. It also offers a (little hidden) way for assigning shortcuts for these scripts.

So the strategy is:

  1. install npp_exec, you find it in the plugin manager and restart notepad++
  2. create a npp_exec script with this content: NPP_SENDMSG WM_COMMAND IDM_SEARCH_FIND, save it, e.g. as OpenFindDlg, you create such a script by Plugins -> NppExec -> Execute..., enter the script and click Save...
  3. Go to Plugins -> NppExec -> Advanced Options ...
    1. Select OpenFindDlg under Associated script
    2. give it a menu entry under Item name: e.g, OpenFindDlg
    3. Click Add/Modify, you want to get a new entry in the list area on the left, see screenshot: NppExec Advanced Options filled
  4. restart Notepad++, so get this setting activated.
  5. add the additional shortcut: goto Settings -> Shortcut mapper: somewhere under the Plugins tab, you will find the Name that you have saved the script, here OpenFindDlg. Now you can assign your shortcut CTRL-G.
    Take care that you have also deleted the existing keybinding CTRL-G for the goto line command somewhere under the Main menu Tab.

Upvotes: 4

Related Questions