This makes use of the vimgrep command, normally used as a "find in files" utility, but here limited to search the current file only. In Vim 7.0 and later, see :help :vimgrep for help on this tool. Alternatively, you could replace "vimgrep" with "grep", and set the grepprg option (see :help 'grepprg'. For example, you might use set grepprg=C:\bin\grep.exe\ -niH on a win32 system.

Here are some mappings to avoid needing to type :cnext and :cprev to move through the quickfix window.

Of course if you do not want the syncing with taglist.vim simply remove :TlistSync.

Now, the advantage of having s:Fancy_Quickfix_Cmd() is that we can conditionally do something based on the command, or some other attribute. In this case we function the same for all commands (and just blindly execute them). We do check to see if the taglist window is open and if so ask it to Sync, if it is not, we don't. One other (minor, cosmetic) advantage to this is we see the user command in the echo area and not the last command executed (as with just the pure mapping method directly above).

Another way to list occurrences in the current file would be

:g//p

with the text you want to list as your current search pattern. See :help :g and :help :p)

Of course, :cnext can be abbreviated to :cn, and :cprev can be abbreviated to :cp.