GtkSourceView is a big boy now
Posted by Adi | Filed under English, Free Software, Planet Ubuntu
Vim is a nice text editor and I’m happy to use it for editing various source code and configuration files on remote servers, but on my desktop I prefer Gedit as I am more comfortable writing plugins in Python.
I have made some customization to QuickOpen and improvements to SessionSaver (waiting to be approved upstream) plugins and together with the wonderful Python checker from GDP Format plugin provided by Curtis Hovey and File Search Mod by Oliver Gerlich, Gedit is turning out to be a nice IDE.
One of my major annoyances with Gedit was Python highlighting as by default it does not highlights trailing spaces, tab indentation or long lines.
After reading GtkSourceView Language Definition tutorial I was able to modify the color scheme and Python language definition to do exactly what it was missing. Here is the result:
The files are on my Launchpad:+junk repository (just look after python:style at the end of the files).





April 21st, 2010 at 09:44
Although it’s not exactly the same, I find the ‘draw spaces’ plugin also very useful (the plugin simply exposes the draw spaces functionality of gtksourceview). What kind of changes did you make to quickopen?
April 21st, 2010 at 10:22
Nice! Do please get this upstream
April 21st, 2010 at 10:58
What’s wrong with gvim? Apart of having the same editor for local and remote editing…
April 21st, 2010 at 11:41
Nice! Just a small typo I noticed in your python.lang file: the python-class and python-interface definitions at the end look mixed up and the word interface is misspelt. Maybe you should send the patch upstream?
April 21st, 2010 at 12:46
I believe the latest version of the “Draw Spaces” plugin can behave differently for leading/trailing tabs/spaces. Which doesn’t quite get what you did, since it won’t be language specific… but it may be useful to know.
April 21st, 2010 at 13:58
Draw spaces is not solving my problem since I want only a warning for leading tags, trailing spaces, long lines, not a permanent reminder.
I will let the upstream know about these changes but I am not sure if they want them… since the long lines warning is hardcoded, there are no Interfaces in Python and some people will still want to use tabs
Regarding Vim, like I said in the beginning, I don’t like writing extensions in Vimscript, Python is way more nicer for me.
I will come back with a blog post about customizing QuickOpen.
April 21st, 2010 at 14:01
Very nice solution to what has been bugging me for ages! I want to see my useless whitespace, so I can eliminate it..
I tried to implement the same thing for the ’sh’ language specs. However I can not get it to work there. Very strange since it’s almost a copy of your work on the ‘py’ language specs.
[Edit by Adi] fill free to contact me via email for support and assistance on extending other languages. The leadings tabs are also nice in Makefiles.
April 21st, 2010 at 15:51
You can write plugins for Vim in Python as well:
http://zerokspot.com/weblog/2009/02/22/getting-to-know-vims-python-interface/
April 22nd, 2010 at 23:05
I know it’s faux pas to use tab indentation in Python, but it still compiles with tabs, so why highlight it?
April 22nd, 2010 at 23:19
Just like you can write code using tab as indentation, you can write code with trailing spaces, long lines … etc.
I have made these changes to help me stick to a certain coding convention.