sponsor Vim development Vim logo Vim Book Ad

Quich Filter : Quickly filter all matches of a string, browse the list, and jump back quickly.

 script karma  Rating 313/88, Downloaded by 3692  Comments, bugs, improvements  Vim wiki

created by
Niels Aan de Brugh
 
script type
utility
 
description
This plug-in provides filtering/search functionality to Vim, similar to e.g.
PSPad. This plug-in offers a number of additional features:

- Further filtering/searching inside the filtered results.
- Syntaxt highlighting in the filtered results.
- Show context line around found matches. You can dynamically change the number
  of lines.
- Easy jumping to and from the filter buffers, including auto-follow.

In addition, the new 2.0 version (currently work in progress!) offers:
- Fine-tuning of results (AND, OR and AND-NOT)
- Showing context lines above, below or above and below the matches.
- Show the raw results (no line numbering) for easy yanking.

The search results are presented in a separate buffer (and window) and the
script offers a number of convenience key-mappings to navigate from one result
to the next.

There are no default mapping to start the plug-in, but setting this up can be
as easy as cut-n-paste from the help file. In the results buffer a number of
mappings are set up, please refer to the help file for an overview in 2.0. For
older releases, press ?. Since ? is a useful VIM command it's no longer mapped
in 1.0.7. In a results window, type ":call ShowHelp()" and press enter.
 
install details
Drop this file in your plug-in directory, e.g. $HOME/vimfiles/plugin or
C:\Program Fles\vim\vimfiles\plugin, and it should be automatically sourced
during start-up.
 

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
filtering2.zip 2.0beta1 2011-12-22 7.0 Niels Aan de Brugh I probably made a mistake during benchmarking this summer because after some more testing I found out the latest alpha version was about 10 times slower than 1.0.6.1 on certain files. Benchmarking was done on a US dictionary file, so lots of small lines.

1.0.7 has the same problem (it uses the same sorting routine as 2.0alpha3, otherwise it's identical to its predecessor).

This version brings back the sorting code of 1.0.6, and should be much faster on bigger files. Let me know if you see performance regression, and be sure to tell me what type of files you're filtering.

Thanks to Yeung for bringing this to my attention.
filtering2.zip 2.0alpha3 2011-08-12 7.0 Niels Aan de Brugh Bugfixes, bugfixes.
Provide some nicer user feedback (call done() after each method chain). Show setting value when toggling. Provide functionality to just count results (split up some methods for more control).
The help file is not yet updated, but this version should definitely be more usable than the previous one. Still alpha though!
filtering2.zip 2.0alpha2 2011-08-11 7.0 Niels Aan de Brugh Bugfixes, mainly for using extra patterns.
filtering2.zip 2.0alpha2 2011-07-19 7.0 Niels Aan de Brugh Unix line endings.
filtering2.zip 2.0alpha 2011-07-18 7.0 Niels Aan de Brugh An alpha release of a complete redesign of the plug-in code. It should be much faster than 1.0.6.1, and about as fast as the 1.0.7 version that I just uploaded.

The API of this plug-in is completely different than before.

Consult the help file in the ZIP to see the details.

This is very much a work in progress! I use my own plug-in mainly for work, and since it's summer I haven't had the chance for some serious dogfooding. In summary I added some functionality that I was missing in the first version, and existing functionality should be more accessible.

Some highlights:

* More fine-grained filtering: gather results that match one or more alternatives (OR-semantics), if these lines also match zero or more other terms (AND-semantics), until they match zero or more even other terms (AND-NOT).
There's no real need any more to filter the results again, you can just use AND.
I think weeding out results using AND-NOT can be very useful too, for example you can quickly grep for all logging of a certain component, and quickly remove debug-level logging. This was not possible before (without using fragile tricks as I've been doing myself).

* Switch between highlighted line-numbered view (the default) and a "raw" view where you just see the plain text results without any line numbering. (Note that this disable pretty much all of the functionality of the plug-in as well.)
Nice for yanking text, for example when writing a problem report where the original line numbers are irrelevant.

* Search for an extra pattern (existing functionality), but not just N lines ahead. You can now also specify a stop-pattern. So you can now look for lines matching M if they match pattern E(xtra) before pattern S(top). The default stop pattern is the empty line.
I think this will be useful when filtering protocol log files that contain decoded messages separated by a blank line.
filtering.vim 1.0.7 2011-07-18 7.0 Niels Aan de Brugh A significant speed-up that I copied from the new 2.0 alpha source after doing some profiling on that code.

Also ? is no longer mapped to help, since it's used for searching (doh!).
filtering.vim 1.0.6.1 2010-10-05 7.0 Niels Aan de Brugh Fixed strange resize behavior when refreshing results, and made resizing more robust for when search and/or original buffer are hidden.
filtering.vim 1.0.6 2010-10-05 7.0 Niels Aan de Brugh This version features:

- Defaults for configuration have been moved to global variables so you specify them without changing the plug-in source.
- Filter a match only if it followed by another match (within a given number of lines). For example, aap|5|noot will match  "aap",  but only if it's followed by "noot" within 5 lines.
- Showing all context lines up to the second match can be switched on/off (regardless of the number of context lines showing already).
- The window size is by default no more than the minimum of the number of matches and half the window size. The maximum can also be configured (absolute or as a percentage of the original window size).

Press ? in a filter window to show all default binding.

I should probably write up some documentation for this some day. For now please refer to the topmost section of the source.
filtering.vim 1.0.3.2 2010-07-30 6.0 Niels Aan de Brugh Unix line endings.
filtering.vim 1.0.3.1 2010-07-29 6.0 Niels Aan de Brugh Made some functions less dependent on custom mappings.
filtering.vim 1.0.3 2009-09-09 7.0 Niels Aan de Brugh Fixed error where ,F always searched for ":echo".
filtering.vim 1.0.2 2009-09-03 7.0 Niels Aan de Brugh Another bug found by a helpful user: called FancyEcho instead of s:FancyEcho in a couple of places. This is now fixed.
filtering.vim 1.0.1 2009-09-02 7.0 Niels Aan de Brugh No longer change the global wrapscan setting. Use an emulation for the j/k keys.
filtering.vim 1.0 2009-08-28 7.0 Niels Aan de Brugh Initial upload
ip used for rating: 18.191.239.123

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.
   
Vim at Github