blob: d2eac8055859b67621eb093742686123c0bc4021 [file] [log] [blame]
Bram Moolenaar03413f42016-04-12 21:07:15 +02001*logiPat.txt* Logical Patterns Jun 22, 2015
Bram Moolenaare2db6c92015-06-19 18:48:41 +02002
3Author: Charles E. Campbell <NdrOchip@ScampbellPfamily.AbizM>
Bram Moolenaar03413f42016-04-12 21:07:15 +02004Copyright: (c) 2004-2015 by Charles E. Campbell *logiPat-copyright*
Bram Moolenaare2db6c92015-06-19 18:48:41 +02005 The VIM LICENSE applies to LogiPat.vim and LogiPat.txt
6 (see |copyright|) except use "LogiPat" instead of "Vim"
7 No warranty, express or implied. Use At-Your-Own-Risk.
8
9==============================================================================
Bram Moolenaar03413f42016-04-12 21:07:15 +0200101. Contents *logiPat* *logiPat-contents*
Bram Moolenaare2db6c92015-06-19 18:48:41 +020011
Bram Moolenaar03413f42016-04-12 21:07:15 +020012 1. Contents.................: |logiPat-contents|
13 2. LogiPat Manual...........: |logiPat-manual|
14 3. LogiPat Examples.........: |logiPat-examples|
15 4. Caveat...................: |logiPat-caveat|
16 5. LogiPat History..........: |logiPat-history|
17
Bram Moolenaare2db6c92015-06-19 18:48:41 +020018
19==============================================================================
Bram Moolenaar03413f42016-04-12 21:07:15 +0200202. LogiPat Manual *logiPat-manual* *logiPat-man*
Bram Moolenaare2db6c92015-06-19 18:48:41 +020021
Bram Moolenaar03413f42016-04-12 21:07:15 +020022 *logiPat-arg* *logiPat-input* *logiPat-pattern* *logiPat-operators*
Bram Moolenaare2db6c92015-06-19 18:48:41 +020023 Boolean logic patterns are composed of
24
25 operators ! = not
26 | = logical-or
27 & = logical-and
28 grouping ( ... )
29 patterns "pattern"
30
31 :LogiPat {boolean-logic pattern} *:LogiPat*
32 :LogiPat is a command which takes a boolean-logic
Bram Moolenaar03413f42016-04-12 21:07:15 +020033 argument (|logiPat-arg|).
Bram Moolenaare2db6c92015-06-19 18:48:41 +020034
35 :LP {boolean-logic pattern} *:LP*
36 :LP is a shorthand command version of :LogiPat
Bram Moolenaare2db6c92015-06-19 18:48:41 +020037
Bram Moolenaar03413f42016-04-12 21:07:15 +020038 :LPE {boolean-logic pattern} *:LPE*
Bram Moolenaare2db6c92015-06-19 18:48:41 +020039 No search is done, but the conversion from the
40 boolean logic pattern to the regular expression
41 is performed and echoed onto the display.
42
43 :LogiPatFlags {search flags} *LogiPat-flags*
44 :LogiPatFlags {search flags}
45 LogiPat uses the |search()| command. The flags
46 passed to that call to search() may be specified
47 by the :LogiPatFlags command.
48
49 :LPF {search flags} *:LPF*
50 :LPF is a shorthand version of :LogiPatFlags.
51
52 :let pat=LogiPat({boolean-logic pattern}) *LogiPat()*
53 If one calls LogiPat() directly, no search
54 is done, but the transformation from the boolean
55 logic pattern into a regular expression pattern
56 is performed and returned.
57
58 To get a " inside a pattern, as opposed to having it delimit
59 the pattern, double it.
60
Bram Moolenaar03413f42016-04-12 21:07:15 +020061
Bram Moolenaare2db6c92015-06-19 18:48:41 +020062==============================================================================
Bram Moolenaar03413f42016-04-12 21:07:15 +0200633. LogiPat Examples *logiPat-examples*
Bram Moolenaare2db6c92015-06-19 18:48:41 +020064
65 LogiPat takes Boolean logic arguments and produces a regular
66 expression which implements the choices. A series of examples
67 follows:
68>
69 :LogiPat "abc"
70< will search for lines containing the string :abc:
71>
72 :LogiPat "ab""cd"
73< will search for lines containing the string :ab"c:
74>
75 :LogiPat !"abc"
76< will search for lines which don't contain the string :abc:
77>
78 :LogiPat "abc"|"def"
79< will search for lines which contain either the string
80 :abc: or the string :def:
81>
82 :LogiPat !("abc"|"def")
83< will search for lines which don't contain either
84 of the strings :abc: or :def:
85>
86 :LogiPat "abc"&"def"
87< will search for lines which contain both of the strings
88 :abc: and :def:
89>
90 :let pat= LogiPat('!"abc"')
91< will return the regular expression which will match
92 all lines not containing :abc: . The double quotes
93 are needed to pass normal patterns to LogiPat, and
94 differentiate such patterns from boolean logic
95 operators.
96
97
98==============================================================================
Bram Moolenaar03413f42016-04-12 21:07:15 +0200994. Caveat *logiPat-caveat*
Bram Moolenaare2db6c92015-06-19 18:48:41 +0200100
101 The "not" operator may be fragile; ie. it may not always play well
102 with the & (logical-and) and | (logical-or) operators. Please try out
103 your patterns, possibly with :set hls, to insure that what is matching
104 is what you want.
105
Bram Moolenaare2db6c92015-06-19 18:48:41 +0200106
Bram Moolenaar03413f42016-04-12 21:07:15 +0200107==============================================================================
1083. LogiPat History *logiPat-history*
109
110 v4 Jun 22, 2015 * LogiPat has been picked up by Bram M for standard
111 plugin distribution; hence the name change
Bram Moolenaare2db6c92015-06-19 18:48:41 +0200112 v3 Sep 25, 2006 * LP_Or() fixed; it now encapsulates its output
113 in \%(...\) parentheses
Bram Moolenaar03413f42016-04-12 21:07:15 +0200114 Dec 12, 2011 * |:LPE| added
Bram Moolenaare2db6c92015-06-19 18:48:41 +0200115 * "" is mapped to a single " and left inside patterns
116 v2 May 31, 2005 * LPF and LogiPatFlags commands weren't working
117 v1 May 23, 2005 * initial release
118
Bram Moolenaar03413f42016-04-12 21:07:15 +0200119
Bram Moolenaare2db6c92015-06-19 18:48:41 +0200120==============================================================================
121vim:tw=78:ts=8:ft=help