How do I delete associated symbols when using Notepad++?

Viewed 120

So lets say I have the argument pyautogui.typewrite(["tab"]) and I want to remove the [] brackets to switch from a key to a string, when I click in-front of the last bracket is shows the first bracket highlighted as-well. How do I delete the first bracket at the same time as the last bracket? There must be a way since both brackets are highlighted before I delete last bracket.

1 Answers

Steps to follow,

  • In the Macro Menu, click Start Recording and perform the below steps
  • Select the text you want to remove the square brackets from
  • Use the shortcut Ctrl + H to open the Replace window
  • Use this regex \[|\] in the Find what field and replace it with an empty string
  • Make sure you check the In selection box and select Regular Expression in Search Mode section
  • Click Replace All
  • Close the Replace window and under the Macro Menu, click Stop Recording
  • Test the recorded macro using the Playback option in the Macro Menu
  • If satisfied, save the recorded macro by selecting Save Current Recorded Macro under Macro menu and then assign a shortcut to it

Note: \[|\] this regex matches either [ or ]

Alternatively, you can just edit your shortcuts.xml file by adding this to the Macros section,

<Macro name="test" Ctrl="yes" Alt="yes" Shift="yes" Key="68">
   <Action type="3" message="1700" wParam="0" lParam="0" sParam="" />
   <Action type="3" message="1601" wParam="0" lParam="0" sParam="\[|\]" />
   <Action type="3" message="1625" wParam="0" lParam="2" sParam="" />
   <Action type="3" message="1602" wParam="0" lParam="0" sParam="" />
   <Action type="3" message="1702" wParam="0" lParam="896" sParam="" />
   <Action type="3" message="1701" wParam="0" lParam="1609" sParam="" />
</Macro>

Here, the name of the macro is test and the shortcut assigned is Ctrl+Shift+D (ASCII value of D is 68)

Related