sponsor Vim development Vim logo Vim Book Ad

f.vim : Function that shows lines that do contain a given regexp. The rest is folded.

 script karma  Rating 107/40, Downloaded by 3197  Comments, bugs, improvements  Vim wiki

created by
Antonio Colombo
script type
:call F()
This function lets you see all the lines in a file
that contain a given regular-expression.

The remaining lines are folded with the manual method,
and can be opened to see some 'nearby' line.

If no regular expression is specified, the last regular expression
specified for search is utilized.

The idea comes from the mainframe ISPF editor.

After you get your folds, you can give commands affecting only the folded lines


or use:


to operate only on the visible lines.

zo   to open a fold a bit
zozj to open a fold a bit and leave the cursor on the fold line
zO   to open a fold completely
zE   to open all folds

zf{motion} to close folders 'a bit more' (or to create folders)
If you have 2 adjacent folders, zf<ENTER> will 'merge' them.
In the same way a visible line can be 'added' to a nearby folder.

:call FA()
This function is similar to F() above, except instead of typing in
a regular expression, the current word the cursor is over is used as
the regular expression.

The function FA() has been prepared and added by:
Ken Huisman - ken.huisman@gmail.com

Suggested mappings:
:map <F5> :call F()<CR>
:map <F6> :normal zozj<CR>

:<Up> to recall the macro after having executed it once

editing the "f.vim" file itself:

try giving as an expression  nfold
try giving as an expression  as
try giving as an expression   as     [that is: ' as' ]
try giving as an expression  let
try giving as an expression  ^":
try giving as an expression  :fun\|:endf
try giving as an expression  :endf
try giving as an expression  ^:endf

for remarks, complaints, etc. write to: azc100@gmail.com
version 05042001
install details
source the file
:so f.vim

:call F()

:call FA()

"f.vim" can also be added to the .vimrc file
There are a few suggested mappings, but they are commented.
If you wish to use them, put them (uncommented :-) in your .vimrc file.

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
f.vim 05051001 2005-05-10 6.0 Antonio Colombo Added a modification introduced by Paul Wei. When no search string is specified, the one remembered from the last search command is used instead.
f.vim 05042001 2005-04-20 6.0 Antonio Colombo Comments modification, thanks to Alexander Langer
f.vim 05011901 2005-01-19 6.0 Antonio Colombo Added new function FA() written and contributed by
Ken Huisman [ken.huisman@gmail.com]. The current word the cursor is over is used as the regular expression to search.
f.vim 03121201 2003-12-12 6.0 Antonio Colombo Modified as per suggestions/corrections from Michael Fitz and Jean-Marc Frigerio. Mainly diagnostics and highlighting.
f.vim 02070801 2002-07-08 6.0 Antonio Colombo Added :foldenable to be able to use the function also while inside :help
f.vim 02062101 2002-06-21 6.0 Antonio Colombo 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.