Similarly as Thunar allows custom actions, the text editor Medit has the same feature. Here’s a little codebit to trim text with Medit.
Medit’s custom actions are under Preferences/Tools. There you will find a bunch of examples from which to learn, both in regular command line syntax and in more advanced scripting languages. This example is a regular command line.
I often need to trim whitespace and delete all line endings (which are left by pressing Enter) in plain text files. The command line which does it:
sed 's/^[ \t]*//;s/[ \t]*$//' | tr '\n' ' '
Custom actions need a label in Medit’s Tools dialog. In this case “Trim” is fitting. Other applicable settings:
- Requires: Document
- Save: Nothing
- Type: Shell command
- Input: Selected lines
- Output: Insert into the document
- Filter: Default