Bram Moolenaar | bc2eada | 2017-01-02 21:27:47 +0100 | [diff] [blame] | 1 | *pi_logipat.txt* Logical Patterns Jun 22, 2015 |
Bram Moolenaar | e2db6c9 | 2015-06-19 18:48:41 +0200 | [diff] [blame] | 2 | |
| 3 | Author: Charles E. Campbell <NdrOchip@ScampbellPfamily.AbizM> |
Bram Moolenaar | 03413f4 | 2016-04-12 21:07:15 +0200 | [diff] [blame] | 4 | Copyright: (c) 2004-2015 by Charles E. Campbell *logiPat-copyright* |
Bram Moolenaar | e2db6c9 | 2015-06-19 18:48:41 +0200 | [diff] [blame] | 5 | 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 Moolenaar | 03413f4 | 2016-04-12 21:07:15 +0200 | [diff] [blame] | 10 | 1. Contents *logiPat* *logiPat-contents* |
Bram Moolenaar | e2db6c9 | 2015-06-19 18:48:41 +0200 | [diff] [blame] | 11 | |
Bram Moolenaar | 03413f4 | 2016-04-12 21:07:15 +0200 | [diff] [blame] | 12 | 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 Moolenaar | e2db6c9 | 2015-06-19 18:48:41 +0200 | [diff] [blame] | 18 | |
| 19 | ============================================================================== |
Bram Moolenaar | 03413f4 | 2016-04-12 21:07:15 +0200 | [diff] [blame] | 20 | 2. LogiPat Manual *logiPat-manual* *logiPat-man* |
Bram Moolenaar | e2db6c9 | 2015-06-19 18:48:41 +0200 | [diff] [blame] | 21 | |
Bram Moolenaar | 03413f4 | 2016-04-12 21:07:15 +0200 | [diff] [blame] | 22 | *logiPat-arg* *logiPat-input* *logiPat-pattern* *logiPat-operators* |
Bram Moolenaar | e2db6c9 | 2015-06-19 18:48:41 +0200 | [diff] [blame] | 23 | 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 Moolenaar | 03413f4 | 2016-04-12 21:07:15 +0200 | [diff] [blame] | 33 | argument (|logiPat-arg|). |
Bram Moolenaar | e2db6c9 | 2015-06-19 18:48:41 +0200 | [diff] [blame] | 34 | |
| 35 | :LP {boolean-logic pattern} *:LP* |
| 36 | :LP is a shorthand command version of :LogiPat |
Bram Moolenaar | e2db6c9 | 2015-06-19 18:48:41 +0200 | [diff] [blame] | 37 | |
Bram Moolenaar | 03413f4 | 2016-04-12 21:07:15 +0200 | [diff] [blame] | 38 | :LPE {boolean-logic pattern} *:LPE* |
Bram Moolenaar | e2db6c9 | 2015-06-19 18:48:41 +0200 | [diff] [blame] | 39 | 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* |
Bram Moolenaar | e2db6c9 | 2015-06-19 18:48:41 +0200 | [diff] [blame] | 44 | LogiPat uses the |search()| command. The flags |
| 45 | passed to that call to search() may be specified |
| 46 | by the :LogiPatFlags command. |
| 47 | |
| 48 | :LPF {search flags} *:LPF* |
| 49 | :LPF is a shorthand version of :LogiPatFlags. |
| 50 | |
| 51 | :let pat=LogiPat({boolean-logic pattern}) *LogiPat()* |
| 52 | If one calls LogiPat() directly, no search |
| 53 | is done, but the transformation from the boolean |
| 54 | logic pattern into a regular expression pattern |
| 55 | is performed and returned. |
| 56 | |
| 57 | To get a " inside a pattern, as opposed to having it delimit |
| 58 | the pattern, double it. |
| 59 | |
Bram Moolenaar | 03413f4 | 2016-04-12 21:07:15 +0200 | [diff] [blame] | 60 | |
Bram Moolenaar | e2db6c9 | 2015-06-19 18:48:41 +0200 | [diff] [blame] | 61 | ============================================================================== |
Bram Moolenaar | 03413f4 | 2016-04-12 21:07:15 +0200 | [diff] [blame] | 62 | 3. LogiPat Examples *logiPat-examples* |
Bram Moolenaar | e2db6c9 | 2015-06-19 18:48:41 +0200 | [diff] [blame] | 63 | |
| 64 | LogiPat takes Boolean logic arguments and produces a regular |
| 65 | expression which implements the choices. A series of examples |
| 66 | follows: |
| 67 | > |
| 68 | :LogiPat "abc" |
| 69 | < will search for lines containing the string :abc: |
| 70 | > |
| 71 | :LogiPat "ab""cd" |
| 72 | < will search for lines containing the string :ab"c: |
| 73 | > |
| 74 | :LogiPat !"abc" |
| 75 | < will search for lines which don't contain the string :abc: |
| 76 | > |
| 77 | :LogiPat "abc"|"def" |
| 78 | < will search for lines which contain either the string |
| 79 | :abc: or the string :def: |
| 80 | > |
| 81 | :LogiPat !("abc"|"def") |
| 82 | < will search for lines which don't contain either |
| 83 | of the strings :abc: or :def: |
| 84 | > |
| 85 | :LogiPat "abc"&"def" |
| 86 | < will search for lines which contain both of the strings |
| 87 | :abc: and :def: |
| 88 | > |
| 89 | :let pat= LogiPat('!"abc"') |
| 90 | < will return the regular expression which will match |
| 91 | all lines not containing :abc: . The double quotes |
| 92 | are needed to pass normal patterns to LogiPat, and |
| 93 | differentiate such patterns from boolean logic |
| 94 | operators. |
| 95 | |
| 96 | |
| 97 | ============================================================================== |
Bram Moolenaar | 03413f4 | 2016-04-12 21:07:15 +0200 | [diff] [blame] | 98 | 4. Caveat *logiPat-caveat* |
Bram Moolenaar | e2db6c9 | 2015-06-19 18:48:41 +0200 | [diff] [blame] | 99 | |
| 100 | The "not" operator may be fragile; ie. it may not always play well |
| 101 | with the & (logical-and) and | (logical-or) operators. Please try out |
| 102 | your patterns, possibly with :set hls, to insure that what is matching |
| 103 | is what you want. |
| 104 | |
Bram Moolenaar | e2db6c9 | 2015-06-19 18:48:41 +0200 | [diff] [blame] | 105 | |
Bram Moolenaar | 03413f4 | 2016-04-12 21:07:15 +0200 | [diff] [blame] | 106 | ============================================================================== |
Bram Moolenaar | 2ed639a | 2019-12-09 23:11:18 +0100 | [diff] [blame] | 107 | 5. LogiPat History *logiPat-history* |
Bram Moolenaar | 03413f4 | 2016-04-12 21:07:15 +0200 | [diff] [blame] | 108 | |
| 109 | v4 Jun 22, 2015 * LogiPat has been picked up by Bram M for standard |
| 110 | plugin distribution; hence the name change |
Bram Moolenaar | e2db6c9 | 2015-06-19 18:48:41 +0200 | [diff] [blame] | 111 | v3 Sep 25, 2006 * LP_Or() fixed; it now encapsulates its output |
| 112 | in \%(...\) parentheses |
Bram Moolenaar | 03413f4 | 2016-04-12 21:07:15 +0200 | [diff] [blame] | 113 | Dec 12, 2011 * |:LPE| added |
Bram Moolenaar | e2db6c9 | 2015-06-19 18:48:41 +0200 | [diff] [blame] | 114 | * "" is mapped to a single " and left inside patterns |
| 115 | v2 May 31, 2005 * LPF and LogiPatFlags commands weren't working |
| 116 | v1 May 23, 2005 * initial release |
| 117 | |
Bram Moolenaar | 03413f4 | 2016-04-12 21:07:15 +0200 | [diff] [blame] | 118 | |
Bram Moolenaar | e2db6c9 | 2015-06-19 18:48:41 +0200 | [diff] [blame] | 119 | ============================================================================== |
Bram Moolenaar | 91f84f6 | 2018-07-29 15:07:52 +0200 | [diff] [blame] | 120 | vim:tw=78:ts=8:noet:ft=help |