Vim Tips Wiki

Simple programmers TODO list using grep and quickfix

Redirected from VimTip391

1,624pages on
this wiki
Add New Page
Talk0 Share
Tip 391 Printable Monobook Previous Next

created December 19, 2002 · complexity basic · author Sean · version 6.0

I use this to maintain a TODO list for projects I am working on. All my projects are pretty small scale with each project stored in it's own directory so this tip was writtten with that in mind. Basically it is two keymappings one which inserts


leaving Vim in insert mode so you can add a note to help you remember what you wanted to do.

The other mapping uses :grep to search for all occurrences of TODO_ITEM in files in the current directory excluding ~ files and then opens the error window displaying the list of TODO_ITEMs.

imap \q <Esc>i//TODO_ITEM<SPACE>
map \q i//TODO_ITEM<SPACE>
imap \w <Esc>:grep --exclude=*~ TODO_ITEM * <CR> :copen <CR>
map \w :grep --exclude=*~ TODO_ITEM * <CR> :copen <CR>

Change the comment style to suit your language and the lame keymappings to something better.


I develop in the same fashion (one project per directory) and developed a program to do exactly this, called devtodo (

Be sure to have 'grepprg=grep -n', because vim needs the line numbers.

You can do this 'quickfix' search for any word under the cursor:

" grep for word under cursor in c/cpp/h-files
map <F9> <Esc>:exec("grep ".expand("<cword>")." ../*/*.c* ../*/*.h")<CR>

"same as menu entry:
22amenu Search.Grep\ for\ word\ under\ cursor <Esc>:exec("grep ".expand("<cword>")." ../*/*.c* ../*/*.h")<CR>

Ad blocker interference detected!

Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.

Also on Fandom

Random Wiki