This plugin provides commands that fold away lines that don't match a specific search pattern. This pattern can be the word under the cursor, the last search pattern, a regular expression or spelling errors. There are also commands to change the context of the shown lines.
The plugin can be found on GitHub and VIM online.
Show lines which contain the word under the cursor.
The optional context option consists of one or two numbers:
- A 'unsigned' number defines the context before and after the pattern.
- If a number has a '-' prefix, it defines only the context before the pattern.
- If it has a '+' prefix, it defines only the context after a pattern.
Default context is current context.
Show lines which contain previous search pattern.
For a description of the optional context please see |:Fw|
Default context is current context.
Show the lines that contain the given regular expression.
Please see |regular-expression| for patterns that are accepted.
Show the lines that contain spelling errors.
Toggle between foldsearch view and original view.
Fold again with the last used pattern
Show or modify current context lines around matching pattern.
For a description of the optional context option please see |:Fw|
Increment context by one line.
Decrement context by one line.
Set modified fold options to their previous value and end foldsearch.
Show debug messages. The debug level can be modified using the setting
g:foldsearch_debug
. The number of debug message lines is limited to the value
of the setting g:foldsearch_debug_lines
Dump debug messages to given file. The debug level can be modified using the
setting g:foldsearch_debug
. The number of debug message lines is limited to
the value of the setting g:foldsearch_debug_lines
<Leader>fw
::Fw
with current context<Leader>fs
::Fs
with current context<Leader>fS
::FS
<Leader>ft
::Ft
<Leader>fl
::Fl
<Leader>fi
::Fi
<Leader>fd
::Fd
<Leader>fe
::Fe
Mappings can be disabled by setting |g:foldsearch_disable_mappings| to 1
Use: let g:option_name=option_value
to set them in your global vimrc.
Highlight the pattern used for folding.
- Value
0
: Don't highlight pattern - Value
1
: Highlight pattern - Default:
0
Disable the mappings. Use this to define your own mappings or to use the plugin via commands only.
- Value
0
: Don't disable mappings (use mappings) - Value
1
: Disable Mappings - Default:
0
Scope for which pattern, display context, original view etc. are stored.
If window
is used, then different types of foldsearch can be done for the
same buffer displayed in several windows. if `buffer? is used, then different
types of foldsearch can be done for several buffers displayed in the same
window.
- Value
window
: Use window scope to store data - Value
buffer
: Use buffer scope to store data - Default:
window
Debug level for storing debug messages in an internal buffer.
- Value
0
: Don't store any debug message. - Value >
1
: Store debug messages up to the given level - Default:
0
Number of debug messages stored in the internal buffer. If there are more debug messages than the given number then the oldest messages will be removed from the buffer.
- Default:
100
To contact the author (Markus Braun), please send an email to [email protected]
If you think this plugin could be improved, fork on GitHub and send a pull request or just tell me your ideas.
- Karl Mowatt-Wilson for bug reports
- John Appleseed for patches
- Adam Szaj for the idea of different scopes
vX.Y.Z : XXXX-XX-XX
- rename internal function FoldSearchContext() -> FoldContext()
- add unit tests
v1.3.2 : 2024-05-02
- add debug messages and functions to dump them on the screen or to a file
- internal refactoring (modify and extend view file instead of storing data in additional variables)
- performance improvements
- bugfix: enable autocommands during restoring previous view again to fix a bug with disabled syntax highlighting after ending foldsearch.
v1.3.1 : 2024-04-26
- bugfix: repeated call to
:Fe
removed folding markers in file
v1.3.0 : 2024-04-25
- add ability to toggle between foldsearch and original view with
:Ft
- respect 'ignorecase' setting for pattern highlighting
- bugfix: refactoring to make
:Fc
work again - bugfix: disable autocommands when restoring previous view to prevent unexpected side effects
- bugfix: for unnamed buffers folds were not correctly restored when foldsearch is finished
v1.2.0 : 2023-10-01
- add abilitiy to choose the scope of foldsearch commands
v1.1.1 : 2014-12-17
- bugfix: add missing
call
to ex command
v1.1.0 : 2014-12-15
- use vim autoload feature to load functions on demand
- better save/restore of modified options
v1.0.1 : 2013-03-20
- added |g:foldsearch_disable_mappings| config variable
v1.0.0 : 2012-10-10
- handle multiline regular expressions correctly
v2213 : 2008-07-26
- fixed a bug in context handling
v2209 : 2008-07-17
- initial version