5

This question was asked several years ago without an accepted answer. The question has also long been inactive. Seems a simple piece of functionality, so perhaps a recent plugin provides the feature.

Say I have the text Hello World!. I'd like to select the text and have it replaced with !dlroW olleH. Ideally this would be a single option completely within Notepad++, either via a plugin or (simple) macro.

Ideally, complicated or non-general macros, regular expressions and external tools (such as online resources) should be avoided, if possible. But if you do know of some cool way to achieve this let me know!

AlainD
  • 5,158

3 Answers3

3

You can use Python Script plugin that can be installed from Plugin Manager (pre Notepad++ v7.5) or from the download site.

  1. Select menu in Plugins > Python Script > Show Console
  2. Select your text in the editor normally (it gives unexpected result with a column/rectangular select mode)
  3. Enter the following code in the Python Console input (next to >>> symbol)
editor.replaceSel(editor.getSelText().decode('utf-8')[::-1].encode('utf-8').replace("\n\r","\r\n"))
  1. Press Enter or click Run

Note: If you selected multiple lines, the order of lines will be also reversed.


Additionally you can save that script by copying the code to a new blank tab, Plugins > Python Script > New Script then save it as "reverse".

Then you can access Plugins > Python Script > Scripts > reverse the next time you need to do the same operation.

1

This isn't in Notepad++ itself, but I've used the site before and it seems to be able to do numerous other things with text.

For now, it might be the easiest option - just copy and paste your text from Notepad++ into the textbox, click Reverse Text, then copy and paste back to Notepad++.

enter image description here enter image description here

Dog Lover
  • 352
0

Solution with little Regular Expression, but using only NotePad ++ (tested on v.8.5.3):

  • (Select sentence to modify if not all the file)
  • Ctrl+h (or Menu SEARCH > Replace...)
  • (Make sure the Regular Expression search mode is selected)
  • Find: "(.)"
  • Replace With: "\1\r\n"
  • Press Replace All
  • Menu EDIT > Line Operations > Reverse Line Order
  • Ctrl+h
  • Find: "(.)\r\n"
  • Replace With: "\1"
  • Press Replace All

All the text in the [selected] sentence should be reversed/mirrored after that.

Regards