Vim Tips Wiki
No edit summary
 
m (reformat)
Line 10: Line 10:
 
|text=
 
|text=
 
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
 
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
  +
<pre>
 
 
//TODO_ITEM
 
//TODO_ITEM
  +
</pre>
 
 
leaving Vim in insert mode so you can add a note to help you remember what you wanted to do ;)
 
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.
 
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.
   
  +
<pre>
 
 
 
imap \q &lt;ESC&gt;i//TODO_ITEM&lt;SPACE&gt;
 
imap \q &lt;ESC&gt;i//TODO_ITEM&lt;SPACE&gt;
 
 
map \q i//TODO_ITEM&lt;SPACE&gt;
 
map \q i//TODO_ITEM&lt;SPACE&gt;
 
 
imap \w &lt;ESC&gt;:grep --exclude=*~ TODO_ITEM * &lt;CR&gt; :copen &lt;CR&gt;
 
imap \w &lt;ESC&gt;:grep --exclude=*~ TODO_ITEM * &lt;CR&gt; :copen &lt;CR&gt;
 
 
map \w :grep --exclude=*~ TODO_ITEM * &lt;CR&gt; :copen &lt;CR&gt;
 
map \w :grep --exclude=*~ TODO_ITEM * &lt;CR&gt; :copen &lt;CR&gt;
  +
</pre>
 
 
   
 
Change the comment style to suit your language and the lame keymappings to something better.
 
Change the comment style to suit your language and the lame keymappings to something better.
 
 
   
 
Sean
 
Sean
Line 48: Line 41:
 
----
 
----
 
You can do this 'quickfix' search for any word under the cursor:
 
You can do this 'quickfix' search for any word under the cursor:
  +
<pre>
 
 
" grep for word under cursor in c/cpp/h-files
 
" grep for word under cursor in c/cpp/h-files
 
map &lt;F9&gt; &lt;ESC&gt;:exec("grep ".expand("&lt;cword&gt;")." ../*/*.c* ../*/*.h")&lt;CR&gt;
 
map &lt;F9&gt; &lt;ESC&gt;:exec("grep ".expand("&lt;cword&gt;")." ../*/*.c* ../*/*.h")&lt;CR&gt;
Line 54: Line 47:
 
"same as menu entry:
 
"same as menu entry:
 
22amenu Search.Grep\ for\ word\ under\ cursor &lt;ESC&gt;:exec("grep ".expand("&lt;cword&gt;")." ../*/*.c* ../*/*.h")&lt;CR&gt;
 
22amenu Search.Grep\ for\ word\ under\ cursor &lt;ESC&gt;:exec("grep ".expand("&lt;cword&gt;")." ../*/*.c* ../*/*.h")&lt;CR&gt;
  +
</pre>
   
 
Thomas
 
Thomas
 
, January 13, 2003 2:54
 
, January 13, 2003 2:54
 
----
 
----
<!-- parsed by vimtips.py in 0.494694 seconds-->
 

Revision as of 12:00, 25 September 2007

Previous TipNext Tip

Tip: #391 - Simple programmers TODO list using grep and quickfix

Created: December 19, 2002 13:25 Complexity: basic Author: Sean Version: 6.0 Karma: 34/22 Imported from: Tip#391

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

//TODO_ITEM 

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.

Sean

Comments

This is a bit of self-advertising, but I develop in exactly the same fashion (ie. one project per directory) and developed a program to do exactly this, called devtodo (http://devtodo.sf.net).

alec aaattttt korn dddotttt ch , December 29, 2002 19:10


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

Anonymous , January 13, 2003 2:51


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> 

Thomas , January 13, 2003 2:54