4

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
  • 4,447
  • 15
  • 49
  • 96
  • this is just a suggestion but if you're that keen on notepad++ or any program then I think it's a bit mistaken to try to do everything completely native with no addons.. it's good to customize it. Just like with windows you customized it in a sense by not just using the native programs but adding notepad++ – barlop Jul 22 '17 at 16:45
  • Fair comment...I'm not against customisation. Do you know of a plugin for Notepad++ that does this? I use a few plugins already, including the excellent `TextFX`. This provides some useful text manipulations (as well as some baffling ones!)...but not the simple ability to reverse text! :o) – – AlainD Jul 22 '17 at 19:51
  • I am not a big user of notepad++ but I'm sure that a macro, whether an easy macro or a "complicated macro" could easily be added as an item in a menu or converted to a plugin and accessed in a menu just like the textfx menu or perhaps added to an existing menu. So you could ask how to make a menu item run a macro, or how to convert a macro to a plugin(then see how to have a plugin add to a menu like textfx does) – barlop Jul 22 '17 at 22:07
  • Fair enough. Hopefully your comment is sufficient to imply such a solution could be offered, or do you think I need to edit the question? – AlainD Jul 22 '17 at 22:14
  • Editing a question too drastically isn't always good move, like if it has some attempts at answering it and those attempts become invalid with an edit to the question. And if a big change one could make it a new question. And who knows what answers may or may not come. Try to find a macro to do it, (often better to experiment/research yourself before asking), then you could set aside the question of reversing characters and look into how to run a macro from a menu, or from a button, or from a keyboard shortcut etc (often better to experiment/research yourself, then ask). – barlop Jul 22 '17 at 22:22
  • None of the answers, including the macro one, were ever accepted. Also, the macro appears to only work for a limited number of characters...so never tried it. Will give it a go, though. I think my question is reasonable. That question was asked over 7 years ago with no answer (apart from my own suggestion!) either new or simple. Surely there is something better in Notepad++ now? – AlainD Jul 22 '17 at 22:27
  • I'd suggest a question of, is it possible in notepad++ for a macro to reverse some characters. I just looked up about macros in notepad++ and it seems they don't even use a language!! They sound rubbish.. You could look into other editors too, like brackets or sublime, those two are very popular with programmers. Sublime uses python.. TextFX does quite a few things so if TextFX can do that then maybe by the same kind of programming, a macro could do what you want. TextFX is maybe open source.. – barlop Jul 22 '17 at 22:29
  • Have edited the question slightly. What do you think? If a reasonable edit, lets delete these comments... – AlainD Jul 22 '17 at 22:36
  • If I were you i'd act more like a software engineer and ask myself how to write a simple macro or plugin to reverse text. And i'd use textfx as a proof that it's possible to do something like it in notepad++ and i'd explore that avenue, and maybe ask a question about that and it'd be technical and programming related enough for stackoverflow.. – barlop Jul 23 '17 at 00:38
  • Would love to develop a plugin offering such functionality for the community...but in the future...I'm also a software engineer with limited time! If someone's done it already, would just use that! :o) – AlainD Jul 23 '17 at 12:07

2 Answers2

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.

user989394
  • 46
  • 3
  • Excellent, thanks! Have found the working x64 version here: https://github.com/bruderstein/PythonScript/releases/tag/v1.0.9. Recommend manual installation (place `python27.dll` in %ProgramFiles%\Notepad++ and the `PythonScript` folder in %ProgramFiles%\Notepad++\plugins). – AlainD Jan 25 '19 at 12:40
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
  • 1
  • 4
  • 15
  • 1
    +1 Good answer, thanks. Not quite `The Answer` since it requires an external tool and an internet connection. – AlainD Jul 24 '17 at 14:02