Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature Request] Line Operation to reverse each line #13714

Open
pigsonthewing opened this issue May 29, 2023 · 3 comments
Open

[Feature Request] Line Operation to reverse each line #13714

pigsonthewing opened this issue May 29, 2023 · 3 comments

Comments

@pigsonthewing
Copy link

pigsonthewing commented May 29, 2023

Please add a line operation to reverse the contents of each line, for example:

abc
123
xyz

would become

cba
321
zyx

Use cases include being able to sort stings by their final component, as demonstrated at:

https://bugs.documentfoundation.org/show_bug.cgi?id=141042

@pigsonthewing pigsonthewing changed the title p[ [Feature Request] Line Operation to reverse each line May 29, 2023
@molsonkiko
Copy link
Contributor

Seems a bit niche, and also regular expressions can achieve this to some extent.
For example, any text with 10 or fewer characters per line can be reversed as follows:
Replace (?-s)(?-s)(.)?(.)?(.)?(.)?(.)?(.)?(.)?(.)?(.)?(.)? with ${10}$9$8$7$6$5$4$3$2$1 (regular expressions on).
Try it out on

abc
ab
h
jklmnopqrs
uvwxyz

And of course any scripting plugin will easily solve your problem:
PythonScript editor.rereplace('(?-s)(.+)', lambda m: m.group(0)[::-1])

@alankilborn
Copy link
Contributor

Seems a bit niche

I agree, IMO, not necessary.

@freezer2022
Copy link

freezer2022 commented Oct 19, 2023

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants