sponsor Vim development Vim logo Vim Book Ad

boolpat.vim : Boolean-logic patterns, based on LogiPat

 script karma  Rating 0/0, Downloaded by 1543  Comments, bugs, improvements  Vim wiki

created by
Andy Wokula
 
script type
utility
 
description
This is just like vimscript #1290 but with simpler syntax.

:BoolPat {expr}

converts boolean-logic pattern {expr} into a normal regexp pattern and searches for it.  Basically, {expr} can be any regexp pattern with some special characters in it for boolean operators:

! is logical NOT, | or || is logical OR, & or && is logical AND
(...) is for grouping, whitespace separates items, '...' quotes characters

Quoting: Single quotes '...' literally include special characters and whitespace in the pattern.  Two single quotes '' result in one single quote, inside or outside of '...'.

:BoolPat abc
will search for lines containing the string "abc", using the pattern .*abc.*

:BoolPat !abc
will search for lines which don't contain the string "abc", using the pattern ^\%(\%(abc\)\@!.\)*$

:BoolPat abc|def
will search for lines which contain either the string "abc" or the string "def"

:BoolPat !(abc | def)
will search for lines which don't contain either of the strings "abc" or "def"

:BoolPat abc & def
will search for lines which contain both of the strings "abc" and "def"

:BoolPat abc' & ''def'
will search for lines which contain the string "abc & 'def"

:BoolPat abc''def
will search for lines which contain the string "abc'def"
 
install details
 

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
boolpat.vim 0.1.1 2012-01-28 7.0 Andy Wokula BF: now adds the search pattern to the search history
boolpat.vim 0.1 2011-12-19 7.0 Andy Wokula Initial upload
ip used for rating: 18.118.12.101

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