Tuesday, September 25th, 2007

gedit todo Hack

UPDATE — Sun 21 Oct 2007
This works for Feisty but not Gutsy. I'll update this hack for Gutsy when I get time.

I'm not sure if anyone will find this little hack useful but I thought I'd post about it anyhow. Basically, I have always kept my to-do list in a simple text file on my desktop. Each new to-do item gets put on its own line in the file and I mark the beginning of each line with an indicator to show whether the item is waiting to be done [-], been done [#]or been canceled [;].

An example of this might look like:

/*
 * stuff to do and stuff that's already been done
 */
- complete report for Mr Smith
- take dog for walk
# blog about todo hack
; fly to the moon
# buy milk
# etc etc

Keeping my to-do list in this fashion has worked great for years and my current to-do list is a couple of thousand lines long. The only problem with my to-do list is it can be hard to read and scan. Enter my gedit hack.

gedit is GNOME's default text editor and I use it to edit my to-do list. One of gedit's great features [it has many more] is its ability to do syntax highlighting. My hack basically involves creating a new language file so that gedit will be able to highlight my to-do items differently depending on their status. Simply follow the instructions below to recreate the hack:

Enter the following command in your terminal:

sudo gedit /usr/share/gtksourceview-1.0/language-specs/todo.lang

Now copy & paste the following lines into the file before saving and closing gedit:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE language SYSTEM "language.dtd">
<language _name="TODO" version="1.0" _section="Others" mimetypes="text/plain">

    <block-comment _name = "Header" style = "Header">
        <start-regex>/*</start-regex>
            <end-regex>*/</end-regex>
    </block-comment>

    <line-comment _name = "Uncomplete" style= "To do">
        <start-regex>-</start-regex>
    </line-comment>

    <line-comment _name = "Complete" style= "Complete">
        <start-regex>#</start-regex>
    </line-comment>

    <line-comment _name = "Cancelled" style= "Cancelled">
        <start-regex>;</start-regex>
    </line-comment>

</language>

Now restart gedit and create a new to-do list file using the syntax shown in my example above. Then from gedit's menu go:

View -> Highlight Mode -> Others -> TODO

And finally, edit how you would like the highlighting to look. Again, from gedit's menu go:

Edit -> Preferences -> Syntax Highlighting

Once you have completed these steps you should have a nice syntax highlighted to-do file. See my example below:

Screen grab of sample to-do list.

Tagged with: gedit, hacks, linux, ubuntu


1 Response to “gedit todo Hack”

  1. Pedro wrote,

    I just loved that tip :D

    Is there any way we can make gEdit activate TODO syntax for .todo files? It would be great if there was… :D

Add Your Comment

Use the form below to add your comment. Markdown syntax is available. Note, comments are moderated by me for spam filtering. Alternatively, feel free to contact me privately.