Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Notepad++: Shortcut for new "Open Containing Folder in ..." menu commands

Tags:

notepad++

Notepad++ v6.5.3+ added new menu commands: Open Containing Folder in Explorer and Open Containing Folder in cmd, but failed to add the new menu items to the Shortcut Mapper so they can be mapped to shortcut keys.

Can I create shortcuts to these commands?

I know there are extensions and run commands that can do similar things, but I would prefer to use the new built-in functionality.

like image 526
infogulch Avatar asked Jan 17 '14 19:01

infogulch


People also ask

Which shortcut key is used to open a new file in Notepad?

Open Notepad by pressing the Windows key (or Ctrl-Esc) and N.

What is the shortcut key help in Notepad?

Ctrl + A: Select all the text or characters on the page. save the note. Ctrl + W: Close the Notepad window. AltGr or F10: Switch the text cursor into the normal select mode.


2 Answers

(TL;DR at the end.)

It turns out you can use Notepad++'s built-in macros to do this, but you'll have to edit them manually (versus recording them).

The file you need to edit is your profile's shortcuts.xml file, usually found in %APPDATA%\Notepad++\shortcuts.xml. Note: you may run into trouble if you try to edit the configuration files with Notepad++ itself.

The accepted answer for How to write macro for Notepad++? mentions using Resource Hacker to look up menu wParams. I got this after opening the notepad++.exe and expanding the first menu section:

resource hacker screenshot

Note the numbers after the quoted strings.

This is the Macros section of my shortcuts.xml file:

<Macros>
    <Macro name="Trim Trailing and save" Ctrl="no" Alt="yes" Shift="yes" Key="83">
        <Action type="2" message="0" wParam="42024" lParam="0" sParam="" />
        <Action type="2" message="0" wParam="41006" lParam="0" sParam="" />
    </Macro>
</Macros>

This is the "Trim Trailing and save" macro that comes in the default installation. Note that in the second Action tag, the wParam value of 41006 matches the Save menu item number listed in the Resource Hacker, this confirms that's the number we need to use, and where we need to put it.

So if you copy that macro, remove the first action tag, give it a new name, and change the wParam attribute of the Action to match the number in Resource Hacker that corresponds to the action you want, you get the following macros which can be pasted in at the end of the list of Macros:

<Macro name="Open Containing Folder in Explorer" Ctrl="no" Alt="no" Shift="no" Key="0">
    <Action type="2" message="0" wParam="41019" lParam="0" sParam="" />
</Macro>
<Macro name="Open Containing Folder in cmd" Ctrl="no" Alt="no" Shift="no" Key="0">
    <Action type="2" message="0" wParam="41020" lParam="0" sParam="" />
</Macro>

Finally, after starting Notepad++ back up again you can go to the Macros section of the Shortcut Mapper and choose the shortcuts you want for them.

TL;DR

Copy the above macros into your shortcuts.xml file and set their shortcuts with the Shortcut Mapper after restarting Notepad++.

like image 155
infogulch Avatar answered Nov 09 '22 03:11

infogulch


Open the file "shortcuts.xml" [filepath: C:\Users\UserName\AppData\Roaming\Notepad++]

Add these 2 lines of code between<UserDefinedCommands> ..</UserDefinedCommands> tag and save it.

<Command name="Open Containing Folder in Explorer" Ctrl="yes" Alt="yes" Shift="no" Key="69">explorer /select,$(FULL_CURRENT_PATH)</Command>
<Command name="Open Containing Folder in cmd" Ctrl="yes" Alt="yes" Shift="no" Key="84">cmd /K cd /d $(CURRENT_DIRECTORY)</Command>

note: you can also customize your keyboard shortcut by changing the value of Ctrl ,Alt,Shift, and Key(ASCII value of the character)

(re)start Notepad++.Now you can see newly added options in "Run" menu

like image 37
jeevan Avatar answered Nov 09 '22 04:11

jeevan