Update on option to <bold>selection</bold>?



  • I’m using Notepad++ v7.8.5 (32-bit) in Windows 7. In 2017, there was a discussion on how to <bold>selection</bold>. The answer was apparently to create a macro, which seems a cumbersome means of achieving such a simple task. Is there now a shortcut for <bold>[single selected word]</bold> and for <bold>[all selected word]</bold> ? Thanks.



  • @Eileen-McGeehan

    macro, which seems a cumbersome means of achieving such a simple task.

    You have to keep in mind that Notepad++ is a general purpose text editor, not an HTML (and similar) editor exclusively.

    Thus, things like your bold request are best left to support items such as macros and scripting languages.

    Thought: Maybe this is something @dail might consider for the Surround Selection plugin, if it doesn’t do it already?



  • @Alan-Kilborn

    For the plugin it’s a little out of scope. The whole need for the plugin was to hook the keyboard input since you cant create a shortcut of something just like [ before Notepad++ would process it.

    This particular use case would probably be better suited for LuaScript or PythonScript since it is basically a macro.



  • Hi @Eileen-McGeehan

    You may not be aware of it, but it is possible to assign a command to a macro. Even both of your requests can be solved with the same macro. So the solution to your needs is quite easy.

    I found the message you are referring to and at that time @guy038 and @scott-sumner posted a suitable macro for the task.

    So you don’t need to create a macro, all you would have to do is to copy it to the shortcuts.xml file. This file is usually found in \AppData\Roaming\Notepad++\shortcuts.xml. Please do as follows:

    1. Stop any instance of Notepad++.

    2. In the macros section of shortcuts.xml paste the following macro:

       <Macro name="Test" Ctrl="no" Alt="no" Shift="no" Key="0">
           <Action type="3" message="1700" wParam="0" lParam="0" sParam="" />
           <Action type="3" message="1601" wParam="0" lParam="0" sParam="(?s).+" />
           <Action type="3" message="1625" wParam="0" lParam="2" sParam="" />
           <Action type="3" message="1602" wParam="0" lParam="0" sParam="&lt;bold&gt;$0&lt;/bold&gt;" />
           <Action type="3" message="1702" wParam="0" lParam="640" sParam="" />
           <Action type="3" message="1701" wParam="0" lParam="1609" sParam="" />
       </Macro>
      
    3. Save shortcuts.xml, close the file and restart Notepad++.

    4. To configure the shortcut, select Settings -> Shortcut Mapper -> Macros, then Test - as the macro is called -, click Modify and assign a command to it and/or rename the macro.

    That’s all.



  • @astrosofista

    Just a note.
    As long as you don’t use the Notepad++ UI to make changes that would affect shortcuts.xml during an editing session, Notepad++ won’t write out that file when it exits.

    What this means is that you can use Notepad++ to edit shortcuts.xml (as you show above), and those changes won’t get trashed.



  • @Alan-Kilborn

    To be honest I do those changes via Notepad++, but when I have to guide another user I prefer to play it safe.


Log in to reply