ifacethoughts

Task Management Using vim

Task management is a sensitive issue. Even the ones who do not explicitly manage tasks are defensive about how they do it. I was one of them for quite some time, till I realized that it was not working anymore. Like design, it is inevitable, it just happens. The problem is that it stops working after sometime and that too without any alarm.

I spent some time using other tools, reading philosophies like GTD and trying to customize it for my needs. Though there were some improvements some tedium was always present, and it sure did follow Matt Blodgett’s first law of software development.

So I set out to figure out my needs.

  • Tasks should be stored in pure text format, so that they are easily available from multiple interfaces. This also reduces the peripheral requirements and makes the system more portable.
  • The task management should work even when the Web connection is not available. This eliminates another big dependency.
  • I work on projects, so I want to group the tasks by projects. The orphan tasks go under unclassified, which is like an unclassified project.
  • A task had to capture the purpose, the action, the context and the constraints like the deadlines.
  • Though grouped by projects, I want to easily retrieve the tasks by timeline.
  • I need to use a tool that is always handy and available to me. Also, I end up working on multiple platforms, so it has to be a cross-platform tool.

I ended up on using vim as my base tool for this. And am I glad for this decision, take a look at this screenshot.

Task management in vim.

Schema

I used a schema to capture all information of the task. I wanted clear separation between different projects, so I decided to use one text file per project. The tasks were prefixed with a - . Every task would have a date, priority, action and status, e.g.,

- Discuss design decisions with xyz =01012007 =high :meet

No status implies the task has not even been started. I prefixed the date and the priority with = because it is one of the symbols easily accessible. The action meet indicates what is required to do so, the other ones I use are phone, email and chat. The actions are prefixed with a : so that they can be easily identified.

A task can have sub tasks, with the same schema. A task can also have its own document child, which I enclose within square brackets. This typically includes progress of the task or details which tend to get verbose a lot of times.

These child elements are indented inside the parent task so that I can use vim folding to use it as an outliner.

So the structure of a project file is:

Project Name *projecttag*

*projecttodo*
- Task 1 description =ddmmyyyy =high =started
    - Task 1a description =ddmmyyyy =done
        [Documentation of task 1a]
    - Task 1b description

I typically also note down project specific information in there, like file paths and contact details of people involved.

Retrieval

Now I need a way of retrieving tasks by time. This is where the power of vim’s scripting comes in. I have the following functions in my .vimrc file.

function! Todo(day, ...)
    " Doing the first separately to clear the location list
    " before adding the first entry.
    let _date = strftime("%d%m", localtime()+a:day*86400)
    try
        exec "lvimgrep /" . _date . "/j ~/wiki/*.txt"
    catch /^Vim(\a\+):E480:/
    endtry

    if a:0 > 0
        " These commands will add results to the location list.
        for offset in range(a:day+1, a:1)
            " Returns 0601 for 1st June.
            let _date = strftime("%d%m", localtime()+offset*86400)
            try
                exec "lvimgrepadd /" . _date . "/j ~/wiki/*.txt"
            catch /^Vim(\a\+):E480:/
            endtry
        endfor
    endif

    exec "lw"
endfunction

command! Today :call Todo(0)
command! Tomorrow :call Todo(1)
command! Dayafter :call Todo(2)
command! Week :call Todo(0, 7)

It uses the lvimgrep command to look for the date pattern in text files under my wiki directory. The date string is formed using the strftime function. The results are stored in the location list and is invoked using the command lw. The try-catch is used to handle an exception when lvimgrep does not find any results. The script works perfectly for me today and lets me manage my tasks from vim, though I am sure that it can be optimized a lot. Also all my project files, which contain tasks by project are stored in ~/wiki/ directory.

Now all I have to do is use :Today command to get today’s tasks. The :Week command retrieves tasks for the whole week from today. This opens the location list in a split window and you can open the file by hitting Enter on the corresponding line. I like to open the file in a separate tab, so I position the cursor on the filename in the result and use gf command. I have mapped gf as:

map gf :tabe <cfile><CR>

It is possible that the function strftime is not available on some platforms. In such cases you can exploit the fact that it is a plain text format and use native scripting language to extract the data out of vim. Here is an example of how shell scripting can be used to retrieve the same data.

alias today='egrep -H `date +%d%m` ~/wiki/*.txt'
alias today+1="egrep -H =`date --date='tomorrow' +%d%m` ~/wiki/*.txt"
alias tomorrow='today+1'
alias today+2="egrep -H =`date --date='2 days' +%d%m` ~/wiki/*.txt"
alias today+3="egrep -H =`date --date='3 days' +%d%m` ~/wiki/*.txt"
alias today+4="egrep -H =`date --date='4 days' +%d%m` ~/wiki/*.txt"
alias today+5="egrep -H =`date --date='5 days' +%d%m` ~/wiki/*.txt"
alias today+6="egrep -H =`date --date='6 days' +%d%m` ~/wiki/*.txt"
alias today+7="egrep -H =`date --date='7 days' +%d%m` ~/wiki/*.txt"
alias week='today;tomorrow;today+2;today+3;today+4;today+5;today+6;today+7'

Syntax Highlighting

However, the task is still not visually parseable. So I used the following syntax file to make that happen.

" Vim syntax file
" Language:	Project
" Maintainer:	Abhijit Nadgouda (http://ifacethoughts.net/)

syntax clear

syn match projTag            "\*[a-zA-z]*\*"
syn match projJump           "|[a-zA-z]*|"

syn match projDate           "=\d\d\d\d\d\d\d\d" contained
syn match projDone           "=done" contained
syn match projHigh           "=high" contained

syn match projKeyword        ":phone" contained
syn match projKeyword        ":email" contained
syn match projKeyword        ":chat" contained
syn match projKeyword        ":meet" contained

syn match projTask      "\-\s.*" contains=projDate,projDone,projHigh,projKeyword
syn match projTaskH     "\-\s.*=high" contains=projDate,projHigh,projKeyword
syn match projTaskD     "\-\s.*=done$" contains=projDate,projDone,projKeyword
syn region projTaskDoc  matchgroup=Comment start=/\[/ end=/\]/

hi def link projTag          String
hi def link projJump         String

hi def link projDate         Constant
hi def link projDone         SpecialChar
hi def link projHigh         SpecialChar
hi def link projKeyword      SpecialChar

hi def link projTask         Statement
hi def link projTaskDoc      Comment
hi def link projTaskD        Comment
hi def link projTaskH        Special

I set the file type for every project file to project by including the line vim:sw=4:ts=4:ft=project at the end of every project file. The syntax file is called project.vim and place it in the syntax directory, which is ~/.vim/syntax/ for me. Needless to say even this can be optimized a lot. If the name project causes problems for you, you can use your name and set the filetype accordingly.

I also tag the projects so that they automatically become part of my wiki. Sometimes I also tag individual tasks, especially if I need to access some of them directly.

I now have a full-fledged task management system, which is organized by projects. Completed projects go in the archive and can be searched whenever required.

vim offers extreme extensibility from all aspects. Even you can modify the scripts, keywords and the syntax highlighting as per your needs and enjoy the power and convenience of vim.

Back To The Future

A college decides to build a web site. The full web site involves offering multiple services. A part of the team has had horrible experiences with downtimes because of too many database calls. So the DB gets eliminated. The site that will host ready-only information gets split into a separate site. [Continue]

vim As A Personal Wiki

vim is an extremely flexible and versatile editor and is one of those tools which have a cult-like following. Typically these tools are liked a lot by these followers and hated by others. So, this post is for those who like to use, or who are open to trying out, vim. One thing I have learnt from experience is that the tool to collect and organize our information must be easily available and easy to use. And that is where vim scores higher than any other tool to build a wiki. [Continue]

It Is Not That Easy To Clone WordPress

I have read quite some tutorials which show how WordPress can be built using certain frameworks in a couple of days or in a matter of seconds. They are quite good, and I personally believe that it helps to write a blogging engine if you want to learn Web programming. Unfortunately these tutorials also lead some to believe that this is all there is to WordPress and ignore its capabilities which are the differentiators, and in my opinion, makes it suitable for much more than just blogs. Of course WordPress is about publishing on the Web, but it offers some capabilities that makes it extremely usable and flexible. Plugins and Extensibility It is quite possible to write a tool that publishes on the Web. [Continue]

Process Styles

I have been reading about REST a lot recently, and hence about architectural styles. Perhaps I have found them in the opposite order. Nevertheless, it has been extremely refreshing and educative. So much so that I saw even SOA in the new light. An architectural style is a coordinated set of architectural constraints that restricts the roles/features of architectural elements and the allowed relationships among those elements within any architecture that conforms to that style. [Continue]

10 Years Of Open Source

It has been a decade since the term open source was chosen to represent the concept. Since then open source has changed the way we develop software and it has changed the way users participate. It has made businesses rethink their business models and has helped the industry evolve new economies. It has given freedom and power to the users to participate and understand something important that they use everyday. It has really impacted every aspect of software business, development and usage. [Continue]

OOXML Is Now An Official Standard

OOXML is an ISO approved standard (press release). Microsoft has also released a public statement acknowledging the approval. All this after an initial rejection and admist a mesh of irregularities. I have been critical of two standards. But this approval will brind sound of money through Government contracts for Microsoft and the associated businesses. [Continue]

Adobe AIR Debuts On Linux

Finally! Adobe AIR is now available on Linux, though it is not a full-featured release yet. The good thing is that this release includes the SDK and Flex Builder 3 along with the runtime. Adobe had left Linux out of their 1.0 release, but now seems to be abiding by its promise. In fact, Adobe has joined the Linux Foundation in a bid to speed up development on Linux. [Continue]

Designing Findability

A List Apart has an informative article by Aarron Walter on Findability. Findability leads to better usage, which can lead to benefits for businesses and individuals. It requires explicit attention and effort to incorporate it in not only during the development but also through all the changes that happen over years. This, I believe, is the biggest reason why it is one of the aspects that gets ignored of pushed down the priority list over time. Findability is a cross-cutting aspect in everything design, right from Information Architecture to usability to SEO and can directly impact your users and hence you. [Continue]

Document Freedom Day

26th March is Document Freedom Day. You can completely ignore it without getting harmed or abused or blamed for being indifferent. But if you know have ever faced a scenario when you could not open a document because did not have a specific office suite, knowing more about document liberation might be worth it. Documents are a critical part of our life. Most of the times they are the meat of what our computers do as desktops. [Continue]

freshcomments

personalfavorites

contactme

Abhijit Nadgouda
iface Consulting
India
+91 9819820312
Y!: anadgouda
GTalk: anadgouda@gmail.com
MSN: anadgouda@hotmail.com
Skype: anadgouda

thoughtfulthoughts

Any fool can write code that a computer can understand. Good programmers write code that humans can understand.
Martin Fowler

badgesand...

Spotplex

This is the weblog of Abhijit Nadgouda where he writes down his thoughts on software development and related topics. You are invited to subscribe to the feed to stay updated or check out more subscription options. Or you can choose to browse by one of the topics.

Twitter - I have been completely thrown off by health problems.