Hacker News new | past | comments | ask | show | jobs | submit login

Recently I decided that I was going to solve the problem of: I easily write inline TODO comments while I work on code, but then have difficulty keeping track of them and getting my head back into the state of things later. While there is IDE support for such things, it's usually not exactly the right interface I want.

So I made a tiny CLI app that scans the source for TODO and FIXME lines and presents a menu of files, containing the number of items to work on in each. Then I type in which file I want to work on and it instantly reports all relevant lines, plus successive comment lines. All I have to do is punch in the line number and start working.

I felt a kind of stress relief almost instantly after doing this. It's better than Trello for me.

If I need to add additional kinds of data sources, many syntaxes, etc. it might become a bit more complex, but still managable as long as there's an API to get some plaintext lines out. It's basically following up on the hypothesis of a lot of information tools today: it isn't the data generation that's the issue, but the filtering.

Just be careful about Microsoft's Patent US6748582B1; it doesn't expire for another few months. ;)

From the patent (edited down a bit):

> According to various example implementations of the invention, a task list facilitates code development by assisting developers in keeping track of and managing a variety of tasks, such as errors to be corrected, opportunities for optimization, and other user-defined tasks. As the developer edits source code, warnings and coding errors are detected and inserted as tasks in a task list. The developer can also embed keywords known as comment tokens in the code. These comment tokens are detected and used to define tasks.

> [...]

> Tasks can also be identified using tokens or keywords. These tokens or keywords typically preface comment lines in the code and may include predefined labels such as, for example, “UNDONE,” “TODO,” or “HACK,” as well as labels that are defined by the individual developer. If the source code has no syntax errors, the parser [...] determines whether any of the keywords are present in the source code[.] If so, [it] extracts the comment from the source code and uses the tag to determine the priority of the task. The task is then inserted in the task list[.] For example, if the source code contains the comment, “/TODO: Need to add copyright text/”, the parser [...] adds the task “TODO: Need to add copyright text” to the task list with a priority rating assigned to the “TODO” tag. [1]

[1] http://patents.google.com/patent/US6748582B1/en

This patent is invalid! Look at the source code in HN comment https://news.ycombinator.com/item?id=21685660#21689915 bellow and see the TODO tags in files last modified on 13. November 1999 which predates the patent application by Microsoft.

That is one of the dumbest patents I have ever seen.

Well.... [0]

I have a whole list of absurd patents... this is the classic go-to example of a patent that should have never been issued... basically, a patent issued saying that if you exercise a cat by moving a laser pointer around a floor, you're infringing on this patent.

[0] https://patents.google.com/patent/US5443036A/en

How is it you are aware of this? Affiliation with MS or a project that ran into it?

Wouldn't the key part:

"and in response to completion of a task, modifying the task list during the interactive code development session to indicate that the task has been completed."

mean it doesn't apply?

Worst case, just put a US exclusionary clause in the release so US copyright law doesn't apply. At least Europe is ahead of the US in this and doesn't allow such trivial patents and considers them invalid by definition.

Someone discovered it years ago online, and it's done a couple rounds in the media[1] as an example of an "overreaching software patent", similar to the "pop-under" patent, which patents a pop-up ad that opens after a window is closed[3].

So no personal experience, but I definitely think it's pretty frivolous; I don't imagine its ever been tested in court. :)

[1] https://www.theinquirer.net/inquirer/news/1040068/microsoft-... from 2004 [2] https://www.geek.com/news/microsoft-granted-patent-covering-... from 2010 [3] https://en.wikipedia.org/wiki/Pop-up_ad#Patent_controversy

I am an X-Microsoft employee. Pre-Nadella era, most teams had a patent budget. People would file patents for all sorts of reasons. The game was who can get away with vague-ish patents and collect the most cubes. There was a cube you got per patent.

Needless to say the number of cubes someone had, the more clout they had and it became a dick measuring contest.

There are VPs and distinguished engineers with 100s of cubes.

Nice idea. The JetBrains family of IDEs (RubyMine, IntelliJ, etc.) even have this as a built-in TODO panel that shows files with TODO and FIXME comments (syntax is configurable).

I use IntelliJ as well for years, but don't underestimate

   grep -r "# TODO" .

That’s great! Using ripgrep [1], I think it would even exclude all from your .gitignore by default.

I’ll give this a try before adding something to my .vimrc again.

1. https://github.com/BurntSushi/ripgrep

grep -H "# TODO" file1 dir1/* file2

Is also useful, as it prints the filename and the matching lines.

if you are using GNU grep, -H option gets enabled by default when there are multiple input files

Hopefully only when stdout isatty().

Edit: Nope, writes l̶i̶n̶e̶ ̶n̶u̶m̶b̶e̶r̶s̶ file names to output regardless. Boo.

you mean filename, not line numbers?

option -h will disable filename in output

This only works depending on how diligently you formatted those TODOs. Before you know it your regex explodes. I use IntelliJ as well, so I don't have to think about these problems.

I mean, how often do you place the four characters "TODO" in your code when you don't mean to mark a TODO? The only common English word I know of that contains that substring is "mastodon", and it'd have to be all-caps.

You could also include word boundaries if you cared enough.

    ag '\bTODO\b'

Does IntelliJ do something smarter than a regex to find TODO?

Visual Studio does the same ("Task List")

I really like JetBrain's Resharper for Visual Studio -- they have a very nice, flexible, and configurable 'TODO' window. For example, on our team we try to put TODO followed by our name or initials. The TODO window can then partition those out into separate lists.

Give Rider a go. I'm a complete convert; previous attempts were very unpleasant, but its a complete experience now, very similar feel to VS + RS, without the awful latency.

I cannot second this enough, Rider is so much nicer than VS these days. I too tried to convert to Rider previously and ended up not using it, but just a while ago I made the switch and spent some time watching some videos on what toys it has, and going through everything and configuring it how I like. It is a lot nicer and a lot quicker, and most importantly to me, has really good vim support (including easymotion / surround ).

I've seen it, but never taken the plunge. Thank you for the encouragement -- I'll definitely give it a go. That said, it's going to be extremely difficult to actually incorporate this in my 9-5 environment, so it will probably end up being for my home projects only.

out of interest, why do you think it'd be hard? It's what I did, just swapped over at work. Nearly everyone else is still using visual studio. It mostly is a zero friction change and you can swap back and forward between environments at any stage

Because I work in a highly regulated industry. We have to qualify/verify/validate everything that we use, and we all have to be standardized on the same thing. I'm currently struggling to get unit tests working smoothly -- we have to validate the "plugin" that we use to execute the unit tests (MSTest... part of Visual Studio), which means that we need to write requirements and then test those requirements. We're writing requirements for MSTest.... I'm pushing to get a CI pipeline set up so that our unit tests can be run automatically with every check-in, but we'll have to write-up requirements for whatever CI tool, validate that it works with our existing source control, validate that the unit tests execute properly, document it all, review it all, sign off on it all within our document control system. etc... Switching to an entirely new IDE I think would make people's heads explode. Personally I think that we make things excessively hard on ourselves -- I'm endeavoring to reduce some of that pain.

That sounds incredibly painful, I admire your tenacity.

Rails (or maybe it's just Rake) has `rake notes`

There's extension for VS Code - Todo Tree that organizes your files with TODO in the comments. Super helpful


Related to this. I write comments for TODOs that I want completed before I commit with a special prefix like:

    //hhh I want this to be done before I commit.
Then have a git pre-commit hook that scans for "//hhh" and aborts if it's found.

Same with XXX instead, which even gets auto-highlighted by many editors.

Have you considered open-sourcing this CLI app? I would benefit immensely from this tool, I think. Right now I just kind of ack and hope for the best.

Emacs supports this with the package magit-todos.

  :set wildignore+=node_modules/**
  :nmap gr :vimgrep '' **/* \| copen 20<Left><Left><Left><Left><Left><Left><Left><Left><Left><Left><Left><Left><Left><Left><Left><Left><Left>
grTODO, enter.

Edit: <C-f>0wa may work instead of Lefts, but I always forget about it.

You reminded me of the time one cool guy and a respectable troll ran a script to create tons of issues on github for TODO comments in the code. He quickly got banned and the issues removed, but I for one was thankful to him. I think I asked the staff to get them back for my repo, but no :)

This could be a Great GitHub Actions though.

So user can enable/disable it per account/repo as they wish.

I think it exists, I've had it enabled in some repo when figuring out new gh actions

I do something similar, but my flow is around feature branches: I create a branch, dumping TODOs in the code as I work out the feature, then progressively fix them before merging the branch. Wrote a little script to highlight TODOs created in current branch (vs base) if anyone's interested: https://github.com/yonilevy/branchtodo

eslint does this for JavaScript with the no-warning-comment rule. The general idea there goes something like "don't use code comments as a project management tool," but I tend to use eslint as a reminder to finish things for my current PR.

Also it occurred to me you could use grep or rg, something like...

  rg '\s*//\s*TODO'

This will open all of the files with TODO in them in vim:

    alias todogrep="vim $(grep TODO . -rl)"
You can modify this easily, such as by using ripgrep, adding excludes, or doing regex to find TODO and FIXME together, but this is a quick one-liner to add to your `.bashrc`.

You can put the grep flags at the end? All these years, and I had no idea.

Depends on your grep. Reordering flags is typically a GNU getopts extension, not present in traditional UNIXes.

Guidelines | FAQ | Support | API | Security | Lists | Bookmarklet | Legal | Apply to YC | Contact