News for hackers. Stuff that matters.
Re:Photoshop for Text by qwerty456127 on Wednesday October 19, 2022 @06:15AM (#33259960)
I wish my text editor had a field where I could enter a snippet of python code which would be fed the opened/selected text to process it and replace it with its output. I often do a lot of logically and sequentially complex search-and-replace which becomes a lot of manual labor. As a simple example" replace all the keyboard quotes with “open-close quote pairs” while making sure the final dot is placed outside rather than “inside the quote.”
Re:Photoshop for Text by Altho on Wednesday October 19, 2022 @06:56AM (#33260274)
would shell commands not be a good way to do that ?
Re:Photoshop for Text by qwerty456127 on Wednesday October 19, 2022 @07:36AM (#33260640)
I do it this way now - push a file through a script in the command line. But I would be more happy with a handy gui-mouse-click-copy-paste solution. Ideally I'd like a panel in something Sublime/Gedit-like where I would just paste a python function, click run and have it applied without even saving the file to the hard drive.
Re:Photoshop for Text by jcparkyn on Wednesday October 19, 2022 @07:07AM (#33260360)
Having a live preview of the diff before any changes were applied (like vscode and most editors do when using find/replace) would make this a lot more useful.
Re:Photoshop for Text by alpaca128 on Wednesday October 19, 2022 @07:22AM (#33260486)
In Vim you can already push marked text through any shell command, including python scripts that read from stdin. You could probably make this work with a few lines and a keybinding.

I rarely need more than the builtin macro system though, as macros can basically do anything including regex-based search it can do any formatting or change as long as the steps stay the same each iteration.

Re:Photoshop for Text by qwerty456127 on Wednesday October 19, 2022 @07:33AM (#33260610)
Vim is not my type, I'd prefer something like Sublime, Kate or Gedit.