One thing that can be quite annoying about python is the fact that program flow depends heavily on line identation. Now, line indentation can be done either with spaces, or with tabs. However, some people write code with the equivalence of 1 tab = 4 spaces (myself included), while others use 1 tab = 8 spaces… This can mess things up, if you’re editing someone else’s code.

This is why, when I start messing with someone else’s code, the first thing I do is convert spaces to tabs. Tabs are tabs everywhere. Depending on your editor settings, you might see the code differently, but the machine interprets it the same everywhere.

So I decided to add the tabconvert plugin to gedit. I downloaded the tarball, extracted the two files into ~/.gnome2/gedit/plugins, and restarted gedit. The new entries where there under the edit menu, however they didn’t seem to do anything. I started playing around to fix this. At first I thought the problem was the “import gedit” statement, a normal python console was giving me “ImportError: No module named gedit”. Then I found out the gedit module is provided by gedit itself at runtime. So I played some more inside gedit’s python console. I found out the problem was with the statement “tabsize = window.get_active_view().get_tabs_width()”. Some googling around told me that “On 2007-09-12 GtkSourceView-2 API renamed get_tabs_view() to get_tab_view().” Changing the two instances of the statement inside fixed it. I’m happy. I’ve emailed the plugin author about it…