sponsor Vim development Vim logo Vim Book Ad

Fdgrep : Find a function declaration matching a given pattern

 script karma  Rating 3/2, Downloaded by 426    Comments, bugs, improvements  Vim wiki

created by
Alex Esplin
script type
This is a script that uses a grep-like regex to find a function declaration in the current file/buffer that matches a given regular expression.

If called like: Fdgrep(-1) the function will ask the user for a pattern to search for.  It will then search the current file buffer for function declarations that contain the given pattern.  If no pattern is given, it will prompt the user again.  If no pattern is given the second time, it will do a search that should match any function declaration.

If called like: Fdgrep(0) the function will ask search for the last-used pattern (like hitting n after a normal search). If there is no last-used pattern in memory it will prompt the user for a pattern, which can be ignored as stated above to match any function declaration.

This will work with most C, C++, Objective-C, and Python function declarations that I have seen in my own code or at my job (we have a _very_ large C codebase).
install details
place the file in your plugin directory.

I use mappings in my .vimrc to make it easier to use, like so:

map \fdg :call Fdgrep(-1)<CR>  " calls Fdgrep with -1 to get a pattern prompt
map \fdn :call Fdgrep(0)<CR> " calls Fdgrep with 0 to use last pattern

rate this script Life Changing Helpful Unfulfilling 
script versions (upload new version)

Click on the package to download.

package script version date Vim version user release notes
fdgrep.vim 1.0 2009-03-13 7.0 Alex Esplin Initial upload
ip used for rating:

If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to the maillist. Help Bram help Uganda.
SourceForge.net Logo