Handy Gedit Features. |
|
Gedit. Not the first program you'd think of when putting together programs. However, second only to vim on the command line (configuration files etc) and givm for zope external editing (easy way to learn vi commands ;)) its fast becoming my favoured program for working on python scripts at work.
So, here are a couple of useful things I do with my gedit, that you might not know of.
Open and work on a file over ssh
Our first task, is opening a file over ssh. I use gedit to edit python scripts on our servers, whilst I'm putting it together. Upside, the script runs on a beefy machine with a large pipe to our database server. (Which is what most of the scripts use, for some task or other.)
My example here, is opening a file called "bob.py" on my machine, over ssh and gedit. I'll be ssh'ing to myself, but you can ssh to anywhere.
So, to start, we open Gedit. Go to "Applications" > "Accessories" > "Text Editor".
Now, we need top open the file. Quick way to open the "Open Location" dialogue we'll use is to hit Ctrl - L, or just click on "File" > "Open Location".
You should now have a box up that looks like this. (Click image for larger version).
Now, we tell it we want to use ssh, and where the file is. The syntax for this is:
<format>://<user>@<machine>/file/location
For this task, I want to use ssh, so I enter:
ssh://jtinsley@localhost/home/jtinsley/Desktop/bob.py
and click open. It asks us for our password. Now, it depends on what you want to do as to which option you pick. Personally, I save permanently. The password is stored in your gnome-keyring, which asks you for your password the first time you use it. This way, auto-save works. Choose your option, enter your password, hit enter, or click "connect".
And bobs your uncle: We're working on our file (that can be stored on a hard-drive 300 miles away...)! Heh.. You know that lame joke is the only reason I called it bob.py, right?
Autosave
This has saved me 10 minutes of work once. You know the times when you're so focused at what you're working on, you forget to keep hitting Ctrl - S to save? It can be a slight pain whilst you're working on a file remotely, because gedit will pause slightly if there's any lag on the line as you upload the file to the remote server, but I don't notice it that often.
Using the same gedit window we opened for bob.py, click on "Edit" > "Preferences". Click on the "Editor" Tab.
At the bottom, under "File Saving" Theres a greyed out tickbox, "Autosave files every N minutes". Click it, and then set the number of minutes. I tend to set it at 5 or two, depending how paranoid I am about my machines' stability at the time ;)
Python Console Plugin
If you're coding python, this is the one for you. Open up the preferences window ("Edit" > "Preferences") and click on the "Plugins" tab. Find, and tick the box next to "Python Console".
Click Close. Now, you might be wondering, "So where is this python console?"
We need to alter our toolbars. Click on "View". You have a set of bars you can activate (or deactivate) across the interface. I will sometimes turn off the "Toolbar", as I don't use it that much... I use the keyboard shortcuts more. Click on "Bottom Pane". A python console will immediatly spawn at the bottom of the window. I use this sometimes if I'm working on a script, and want to look up something quickly, or try out a snippit of code to make sure it runs. You can also use this console to alter/run python on gedit. I've not played with that much, but looks pretty smart.
Note: I've edited a lot of these images to make them smaller.
If you have any comments, feel free to email me them and I'll add them to the site. Still haven't got round to sorting out a captcha, sorry.
- The URL to Trackback this entry is:
- http://trollstomper.org.uk/Members/thumper/the-kirrus-blog/handy-gedit-features/tbping