💾 Archived View for republic.circumlunar.space › users › johngodlee › posts › 2022-06-20-todo.gmi captured on 2022-07-16 at 14:33:29. Gemini links have been rewritten to link to archived content

View Raw

More Information

-=-=-=-=-=-=-

Todo lists in Vim, syntax highlighting

DATE: 2022-06-20

AUTHOR: John L. Godlee

I keep a todo list on my computer, which contains tasks for work and home. It also contains items where I'm waiting for someone to do something, and I use it as a scratchpad for bits of pertinent information that might be useful in the near future. The file is written in Markdown[1]. Items in the list are written as bullet points (-), and sometimes I group items together under headers (#). Sometimes I have headers for each day of the week, and sometimes for a particular project I'm working on. The bullet point list of tasks is sometimes nested to include extra information about each task, or to add subtasks below a main task.

1: https://daringfireball.net/projects/markdown/

I've known about the todo.txt[2] file format for a long time, and I see the logic in it. todo.txt is very flexible and has a number of optional features. You can specify due dates and creation dates (2022-05-05, due:2022-05-05), prioritise tasks using a letter system ((A), (B)), group tasks by project (@project) or context (+context), mark tasks as done ([ ], [x]) and optionally move completed tasks to a separate done.txt file. In my current system I already move tasks to "done" files, one per day, and I often add creation dates and due dates, especially on tasks where I'm waiting for someone to do something.

2: http://todotxt.org/

The thing that has always put me off using todo.txt is the inability to add longer descriptions or subtasks to a task. Each task must occupy a single line. I also like having the ability to group tasks under headers as this allows me to plan my time, but todo.txt requires each line to be a task. Whenever I've dabbled with todo.txt in the past, it's always given me tunnel vision, making it so I can only focus on the next few short tasks ahead of me, at the expense of understanding the wider context of my work. That being said, I would like to start making use of the context and project tags from todo.txt to organise tasks in my todo.md file.

I do most of my task management in neovim[3]. I wrote some syntax highlighting rules to extend the basic Markdown syntax highlighting in vim, by placing a file at ~/.config/nvim/after/syntax/mardown.vim. The file contains:

3: https://neovim.io/

syntax  match  TodoDate  '\d\{2,4\}-\d\{2\}-\d\{2\}'
syntax  match  TodoDue  'due:\d\{2,4\}-\d\{2\}-\d\{2\}'
syntax  match  TodoProject  '\(^\|\W\)+[^[:blank:]]\+' 
syntax  match  TodoContext  '\(^\|\W\)@[^[:blank:]]\+' 

highlight  default  link  TodoDate  Type
highlight  default  link  TodoDue  Constant
highlight  default  link  TodoProject  Comment
highlight  default  link  TodoContext  Statement

So when I open my todo.md it looks like this:

Screenshot of todo.md showing syntax highlighting