Created
May 31, 2021 21:05
-
-
Save jpvanoosten/5b247b127256657a47d38fc4a62ede21 to your computer and use it in GitHub Desktop.
Using the Notepad++ Python Script plugin, you can use Python to perform complex editor operations with a single button. This script replaces the '<' and '>' characters with the HTML equivalents to enable copy-pasting source code into HTML.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# First we'll start an undo action, then Ctrl-Z will undo the actions of the whole script | |
editor.beginUndoAction() | |
selectionLength = editor.getSelectionEnd() - editor.getSelectionStart() | |
start = editor.getSelectionStart() if selectionLength > 0 else 0 | |
end = editor.getSelectionEnd() if selectionLength > 0 else editor.getLength() | |
# editor.replace("&", "&", 0, start, end) | |
editor.replace("<", "<", 0, start, end) | |
editor.replace(">", ">", 0, start, end) | |
# End the undo action, so Ctrl-Z will undo the above actions | |
editor.endUndoAction() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment