32

I use VIM/GVIM to develop my python projects and I randomly I leave #TODO comments in my code.

Is there any way to manage (search, list and link) all the #TODO occurrences inside VIM? I tried the tasklist plugin, it's almost what I need, but it only lists the current file #TODO occurrences. Generally my projects has some sub-folders and many .py files, so I'd like to find a way to search through all folders and files in the current working directory and list them.

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
Magnun Leno
  • 2,728
  • 20
  • 29
  • Thanks for the advice, but I think that an editor switch is out of question **in moment** (I'm in love with VIM). Sorry but I strongly think that switching to an issue tracker just to take a note like "write an exception for this later" or "add this in the unittest" is an waste of time. And I'll take a look at emacs, I swear :). – Magnun Leno Nov 05 '10 at 13:29
  • 1
    @aaronasterling http://vimcasts.org/episodes/cleaning-up-with-vim/ :) – Arnis Lapsa Nov 05 '10 at 13:44
  • @Arnis L., Vimcasts is great, Thanks to Drew Neil I came back to VIM! – Magnun Leno Nov 05 '10 at 14:08
  • 1
    @aaronasterling: If you're so eager to proselytize for emacs, why are you reading and commenting on vim questions? (I don't think that sort of comment is obligatory at all.) – Cascabel Nov 09 '10 at 19:10
  • @jefromi, I generally read everything with a python tag. I didn't notice vim in the title. The proselytizing was mainly a joke: I primarily wanted to say "Use an issue tracker" which is what the only person that answered ended saying as well. – aaronasterling Nov 09 '10 at 21:26

1 Answers1

52

If you just want a list of the occurences of "TODO" in .py files in the working directory, you can just use :vimgrep like so:

:vimgrep TODO **/*.py

Then open the quickfix window with:

:cw

(it might open it automatically anyway, not sure) and just scroll through the results, hitting Enter to go to each occurrence.

For more complicated management, I'd probably recommend setting up an issue tracker.

Liquid_Fire
  • 6,990
  • 2
  • 25
  • 22
  • 11
    Faster is `:noautocmd vimgrep /TODO/ **/*.py` which will not trigger any autocmd while loading files for looking inside them. – Benoit Nov 05 '10 at 13:31
  • 1
    Thats amazing, almost perfect! The only inconvenience it that my cursor jumps to the first occurrence. But I can live with it! – Magnun Leno Nov 05 '10 at 13:53
  • 1
    @Benoit, thats a great tip! I'll use it in my keymapping. `noremap t :noautocmd vimgrep /TODO/ **/*.py` – Magnun Leno Nov 05 '10 at 13:59
  • 4
    @Magnun Leno Looking at the docs, I see you can use the `j` flag to make it not jump to the first occurrence: `:vimgrep /TODO/j **/*.py` – Liquid_Fire Nov 05 '10 at 14:00
  • 11
    @Luquid_Fire, Thats simply amazing! Thanks a lot, it's perfect now! `noremap t :noautocmd vimgrep /TODO/j **/*.py:cw`. VIM rocks! – Magnun Leno Nov 05 '10 at 14:06
  • To navigate in TODO list you can use `:cn 2` or any number to open it in your window! See more in: http://stackoverflow.com/questions/1747091/how-do-you-use-vims-quickfix-feature – squiter Nov 28 '12 at 21:26