3 ms·
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
by qwerty456127 4y ago
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.”
- Altho 4y agowould shell commands not be a good way to do that ?
- jcparkyn 4y agoHaving 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.
- qwerty456127 4y agoI 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.
- alpaca128 4y agoIn 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.
- qwerty456127 4y agoVim is not my type yet (perhaps later as I grow up for it), I'd prefer something like Sublime, Kate or Gedit.