funcsrch.txt  Function Search                       Oct 16, 2012
Author:  Charles E. Campbell  <NcampObell@SdrPchip.AorgM-NOSPAM> - NOSPAM
Copyright:    Copyright (C) 2005-2012 Charles E. Campbell
              Permission is hereby granted to use and distribute this code,
              with or without modifications, provided that this copyright
              notice is copied with it. Like most anything else that's free,
              funcsrch.vim is provided *as is* and comes with no warranty
              of any kind, either expressed or implied. By using this
              plugin, you agree that in no event will the copyright
              holder be liable for any damages resulting from the use
              of this software.

==============================================================================
1. Usage                                  funcsrch :FS :FSB

<funcsrch.vim>, which provides two command-line commands:

  :FS pattern        - search forwards  in function source for pattern
  :FSB pattern       - search backwards in function source for pattern

This assumes that the cursor is inside the source code of some function; the
search will remain restricted to the function's extent.  It uses the [[ and
][ normal mode commands to determine that extent.  Normally the [[ and ][
commands are defined to support C-style functions, but of course one may
customize them.  For example, if inside the file

 .vim/ftplugin/vim/vim.vim

you have

    " Support function jumps: {{{1
    noremap <buffer> <silent> [[ zO:call search('^\s*fu\%[nction]\>','bW')<CR>zMzv
    noremap <buffer> <silent> ]] zO:call search('^\s*fu\%[nction]\>','W')<CR>zMzv
    noremap <buffer> <silent> [] zO:call search('^\s*endf*\%[unction]\>','bW')<CR>zMzv
    noremap <buffer> <silent> ][ zO:call search('^\s*endf*\%[unction]\>",'W')<CR>zMzv

then [[ and ][ are defined for vim source code functions (all that z... stuff
handles folds).  Similarly, one may define such normal commands for other
languages.  As another example, consider paragraphs in regular text:

    " Support paragraph jumps: {{{1
    noremap <buffer> <silent> [[ zO{zMzv
    noremap <buffer> <silent> ]] zO}zMzv
    noremap <buffer> <silent> [] zO{zMzv
    noremap <buffer> <silent> ][ zO}zMzv

You can get the latest funcsrch plugin from

   http://www.drchip.org/astronaut/vim/index.html#FUNCSRCH

The search pattern is re-usable (ie. hit n or N, for example).  Searching
starts from your current cursor location.  A plain ":FS" will re-use the
last search pattern.

FuncSrch(), believe it or not, also can be used to aid in doing substitutes!
As an example, consider the following sequence:

    :FS pattern
    :g//s/something/else/g

This takes advantage of the pattern having been stored in the @/ register; it
gets re-used by the g// command.  Thus, the substitute can apply to change
all occurences of "something" into something "else" only on lines containing
the pattern; again, only affecting those lines which are in your function.

==============================================================================
2. History                                    funcsrch-history
   v2  Jan 25, 2006  * SaveWinPosn(0) used to avoid use of SWP stack
   v1  Nov 10, 2005  * initial release

vim: ts=4