Gary Haran.com


Gemini Gedit Plugin For All Those TextMate Fans

Posted in Programming by gary.haran on the November 16th, 2006

update: I’ve switched to OS X full time at work and at home and with other impending projects I’m unable to continue working on this plugin. I’m glad to say it is open source and I won’t feel bad if someone grabs it and makes it better so long as they mention me in the source code.

Gemini Gedit Plugin completes characters we often see together. Anyone who wants to speed up their typing with smart completion ought to check it out. It is compatible with the acclaimed Snippets plugin and requires the latest version of pygtk installed (comes with Ubuntu Edgy).

Things it does:

  • Completes the following characters: < {['""']}>
  • deletes both inserted characters on backspace or deletes only the closing character if you hit delete
  • inserts proper indentation when you hit the Enter between {}
  • pads selected text with a pair when you type the starting character

It is my first Gedit plugin and my first ’serious’ python script. I decided to GPL the code because I like doing what’s right.
To install simply drop the content of gemini.tar.gz file in the ~/.gnome2/gedit/plugins/ directory or if you have admin rights
to the /usr/lib/gedit-2/plugins/ directory.

Gemini Gedit Plugin

24 Responses to 'Gemini Gedit Plugin For All Those TextMate Fans'

Subscribe to comments with RSS or TrackBack to 'Gemini Gedit Plugin For All Those TextMate Fans'.

  1. S. Potter said,

    on November 21st, 2006 at 4:11 pm

    Hi,

    I am interested downloading the plugin, but I am currently receiving Internal Server Errors when clicking through the link above. Just thought I would let you know. Is there a sourceforge or similar website for the project? I would be willing to use it and provide patches for any bugs I find in my usage.

    Thanks,
    SPP

  2. gary.haran said,

    on November 21st, 2006 at 4:24 pm

    I fixed the link so it should work again now.

    There is no subversion setup yet for this project but I might upload it to sourceforge most likely this week end.

    One of the Gedit developers apparently made a bracket completion tool but this one does a bit more things like TextMate does and I might just continue adding features to make Gedit work more and more like my favorite editor.

  3. Phil Crosby said,

    on November 22nd, 2006 at 1:11 am

    gedit is the best candidate to be a great lightweight, integrated editor for gnome. Gary, if you can start getting features into gedit to make it act like TM, you will be my personal hero. Seriously. I’ll put your picture on my wall and everything.

    I played with your plugin and it works great. I saw a closing brace pop out after I typed an opening brace, and then I typed a closing brace out of habit, and it just overwrote the one that was inserted by the plugin (I love it when eclipse does this too). Beautiful… I almost shed a tear.

    However, I noticed this does not indent:
    examples.each{ |e|
    }

    putting the “|e|” in there throws the indentation off.

    Forget all the fancy stuff, like integrated debugging, advanced file browsing, etc. If we could just get a lightweight editor that handles ruby (and erb) syntax well, indents properly, and just gets out of my way as I type text, that would do a lot to make ruby editing a better experience on gnome.

    BTW, cool name (gemini)

  4. gary.haran said,

    on November 22nd, 2006 at 7:55 am

    Hey Phil,

    I added a fix so it now completes an indentation when it sees a “}” character in front of the cursor rather than when it sees a “{” behind. It should now indent properly in the scenario you described.

    I changed the link and you can download it again if you wish. Keep those comments coming they’ll help the plugin rock.

  5. Alec said,

    on December 12th, 2006 at 5:21 pm

    What I want to do on my blog, is every few hours take the oldest post and move it to the
    front of the queue, all automatically. Anyone know if there is a plugin that can do this or
    a simple way to set up another plugin to do this (use my own feed perhaps)?
    Thanks.

  6. Fergus said,

    on January 31st, 2007 at 12:58 am

    Thank you, thank you, thank you, & cetera.
    Perfect.

  7. Leon Bogaert said,

    on February 27th, 2007 at 5:15 pm

    Nice! Really a very nice plugin. Are there any more plugins like this one?

  8. nephish said,

    on April 17th, 2007 at 12:38 pm

    great plugin.
    i sometimes use gedit for rails stuff when i am on my work box.
    i made a lang file to make gedit support rhtml files, the how-to is at my site.
    www.bitsbam.com

    thanks for your work on this, really smooths the text flow a lot.

  9. nephish said,

    on April 17th, 2007 at 8:26 pm

    sorry, one more comment.
    this thing is great. using it for the last hour. kudos.

  10. Chris said,

    on April 24th, 2007 at 9:43 am

    Am I missing something? I can’t get this to work on Debian Etch (gedit 2.14.4, python-gtk2 2.8.6-8)

  11. Jared A. Scheel said,

    on May 3rd, 2007 at 5:12 pm

    Love your plugin! Thanks for your hard work! One small problem that I have noticed though: nested parentheses overwrite each-other. Try typing “print(getText());” and you’ll see what I mean.

  12. elijah said,

    on May 14th, 2007 at 4:48 pm

    I have ditched radrails in favor of gedit and have never looked back, thanks to this plugin and many other (most notably snap open).

    A few requests:

    (1) would be very appreciated!

    (2) It is my opinion that if you type a “completion character” and the next character is a word character then it should not automatically create the matching pair. This is the behavior my fingers expect, so I assume that this is how eclipse did things, although I have thankfully purged eclipse from my computer.

  13. elijah said,

    on May 14th, 2007 at 4:50 pm

    the erb escape got eaten, but it should have appeared before “would be very appreciated”.

  14. ditocujo said,

    on June 28th, 2007 at 12:26 am

    Hey Gary!

    Excellent plugin! I was planning do one like this myself, but fortunately you did it and did well! Congratulations!

    Just a small comment: On some keyboards configured for international languages, you have to type the key right of the “;” and then space to get an ‘ or “. The plugin doesn’t seem to work with this type of keyboard.

    But that aside it’s a great plugin and a great work you did!

    Best,
    Dante (ditocujo)

  15. philong said,

    on June 28th, 2007 at 3:16 am

    i use debian 4.0, and gemini not woking for gedit(2.14.4).
    Why?

  16. ditocujo said,

    on June 28th, 2007 at 10:27 am

    Hye philong,

    Did you enable it on the GEdit Preferences? (Edit / Preferences / Plugins)?

    Best

  17. philong said,

    on June 29th, 2007 at 4:39 am

    yes. i have enable it. but it can’t woring on my debian 4.0 etch. before this test on debian, i have use gemini on my notebook, that is ubuntu 7.04, and it is good.
    i don’t know if gedit’s version is too low on debian. it is 2.14. and ubuntu’s gedit is 2.18.1

  18. bjarkigud said,

    on January 22nd, 2008 at 12:15 pm

    Hi Gary and thanx a bunch for the plug-in. I am having a slight problem with it though. I have an international keyboard (Icelandic to be precise). The problem is that when I type a character like again it just adds the character instead of overwriting the character generated by the plug-in. Below is an example

    > (is displayed when I type ‘’)

    The same thing happens with all the characters supported by the plug-in.

    Kind regards,
    Bjarki

  19. vince said,

    on January 26th, 2008 at 5:06 pm

    Awesome plugin.. it handles the close of the auto-completed bracket perfectly. Thanks so much!

  20. Kev said,

    on February 19th, 2008 at 11:37 pm

    Hey bud, nice plugin ya got there. Too bad it’s not working correctly in *.RHTML files =[

  21. jero said,

    on April 3rd, 2008 at 12:57 pm

    I love it.
    I only had some issue that I solved later and here i post the solution in case of someone else has it.

    It happened that when I clicked ‘{’ and then ENTER just to have something like:
    {
    [cursor here]
    }

    gedit crashed.

    Then I realized that this happened only when I had the option to Use spaces instead of tab in gedit settings.

    I unchecked that option and it worked great.

    If you still want to use spaces instead of tabs you can change a line in gemini.py :

    go to the end of the file

    find this:

    if view.get_insert_spaces_instead_of_tabs():
    buf.insert_at_cursor(’ ‘ * view.get_tabs_width ())
    else:
    buf.insert_at_cursor(’\t’)

    return True

    replace
    view.get_tabs_width ()
    with the number of spaces you want to be used instead of tabs ie.

    If I want to use 4 spaces instead of tab my code will be:

    if view.get_insert_spaces_instead_of_tabs():
    buf.insert_at_cursor(’ ‘ * 4)
    else:
    buf.insert_at_cursor(’\t’)

    return True

    hope someone find this helpful

  22. Xoan said,

    on April 7th, 2008 at 5:56 am

    Nice plugin, all features works fine (Gnome 2.20.1) except deletes both inserted characters on backspace (deletes only the closing character if I hit delete works).

    I haven’t enough python knowledge (text buffers, text iters… OMG! too complicated for me), but something doesn’t seem to work at this.

    Thanks anyway, plugin is very useful.

  23. Marlun said,

    on April 10th, 2008 at 6:22 am

    Had the same problem as the one before me. Backspace only deletes the first one.

  24. Keith said,

    on April 25th, 2008 at 11:21 am

    Any plans for a configuration screen? Sorry, I don’t know python.

    The single quote rule was driving me nuts on pages where I was creating content, not code so I took the rule out by editing gemini.py - and also added an open % close % rule ( Ruby on Rails views ). ( See my link for blog posting about it )

    Your plugin code has these rules very tidily in the same place, so would be great if some python whiz created a configure screen.

    Thanks again

    Keith

Leave a Reply