Power Editing For Text Files
Using the External Tools Plugin for Gedit
Most text editors fall short on being able to run batch commands with the search and replace features. Gedit overcomes this with the External Tools Plugin which allows us to create scripts and apply these as needed to documents being edited. I'm very happy with it - its powerful and flexible - and does all that it claims.
I didn't realise this was the tool I needed at first as I was sidetracked, thinking the "Python console" plugin would do the job - once I realised the error of my ways, it was easy... but I still had to do some 'digging' through the internet to work out how to use it for what I wanted... a clear "how to" was not easy to find.
Looking back...it was not difficult ... and well worth the effort.
Its flexible in allowing us to use the scripting language we prefer, and making it easy to choose the input text source and output options. My first test used a python search and replace script, applied to the current document, with changes made in place to the document.
How To add a script to the External Tools plugin :
- Enable the External Tools plugin
- Open menu item "Manage External tools"
- Hit "+" on bottom left to add a new tool
- Add your script in the window on the right
- Use the option panel on the bottom right to choose options for source text and output, add a shortcut key if needed.
- Rename the new tool to a suitable name
- Close the "Manage" window - it will be saved automatically
- The new tool will be available under "Tools > External Tools"...and via the shortcut key if you have selected that option.
After this, I tried SED, as the scripting is even simpler for the same task.....
Need a more complex script ... no problem for this glossary markup script
If you have any problem in saving a new tool - check the folder ownership for the local gedit config folder. My Ubuntu system hiccuped on saving the tools until I gave my user ownership of the gedit folder in my user config folder. (sudo chown -R username /home/username/.config/gedit)
Tag: gedit
What's Related