sponsor Vim development Vim logo Vim Book Ad

LogiPat : Boolean-Logic Patterns

 script karma  Rating 147/46, Downloaded by 2818  Comments, bugs, improvements  Vim wiki

created by
Charles Campbell
 
script type
utility
 
description
LogiPat takes Boolean logic arguments and produces a regular expression which is used to search for a line satisfying the logic.  The search register (@/) is initialized with the resulting regular expression, so repeating such searches is as easy as repeating any search.  A series of examples follows:

:LogiPat "abc"
will search for lines containing the string "abc"

:LogiPat !"abc"
will search for lines which don't contain the string "abc"

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

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

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

:let pat= LogiPat('!"abc"')
will return the regular expression which will match all lines not containing "abc".  The double quotes are needed to pass normal patterns to LogiPat, and differentiate such patterns from boolean logic operators.

(alpha/beta version available at http://www.drchip.org/astronaut/vim/index.html#LOGIPAT)
 
install details
LogiPat is distributed via a "vimball":  To install it:
vim LogiPat.vba.gz
:so %
:q
 

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
LogiPat.vba.gz 3 2013-03-13 7.0 Charles Campbell New: :ELP will echo the search pattern that logipat generates.
Fixed: LP_Or fixed; it encapsulates its output in \%(...\) parentheses
LogiPat.vim.gz 2 2006-02-13 6.0 Charles Campbell bugfix : LPF and LogiPatFlags now work
LogiPat.vim.gz 1 2005-05-23 6.0 Charles Campbell Transforms Boolean logic patterns into regular expression patterns.  "abc"|"def", !"ghi", etc
ip used for rating: 142.132.191.50

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