Bram Moolenaar | e2db6c9 | 2015-06-19 18:48:41 +0200 | [diff] [blame^] | 1 | *pi_logipat.txt* Logical Patterns Mar 13, 2013 |
| 2 | |
| 3 | Author: Charles E. Campbell <NdrOchip@ScampbellPfamily.AbizM> |
| 4 | Copyright: (c) 2004-2013 by Charles E. Campbell *logipat-copyright* |
| 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 | ============================================================================== |
| 10 | 1. Contents *logipat* *logipat-contents* |
| 11 | |
| 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 | |
| 18 | ============================================================================== |
| 19 | 2. LogiPat Manual *logipat-manual* *logipat-man* |
| 20 | |
| 21 | |
| 22 | *logipat-arg* *logipat-input* *logipat-pattern* *logipat-operators* |
| 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 |
| 33 | argument (|logipat-arg|). |
| 34 | |
| 35 | :LP {boolean-logic pattern} *:LP* |
| 36 | :LP is a shorthand command version of :LogiPat |
| 37 | (|:LogiPat|). |
| 38 | |
| 39 | :ELP {boolean-logic pattern} *:ELP* |
| 40 | No search is done, but the conversion from the |
| 41 | boolean logic pattern to the regular expression |
| 42 | is performed and echoed onto the display. |
| 43 | |
| 44 | :LogiPatFlags {search flags} *LogiPat-flags* |
| 45 | :LogiPatFlags {search flags} |
| 46 | LogiPat uses the |search()| command. The flags |
| 47 | passed to that call to search() may be specified |
| 48 | by the :LogiPatFlags command. |
| 49 | |
| 50 | :LPF {search flags} *:LPF* |
| 51 | :LPF is a shorthand version of :LogiPatFlags. |
| 52 | |
| 53 | :let pat=LogiPat({boolean-logic pattern}) *LogiPat()* |
| 54 | If one calls LogiPat() directly, no search |
| 55 | is done, but the transformation from the boolean |
| 56 | logic pattern into a regular expression pattern |
| 57 | is performed and returned. |
| 58 | |
| 59 | To get a " inside a pattern, as opposed to having it delimit |
| 60 | the pattern, double it. |
| 61 | |
| 62 | ============================================================================== |
| 63 | 3. LogiPat Examples *logipat-examples* |
| 64 | |
| 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 | ============================================================================== |
| 99 | 4. Caveat *logipat-caveat* |
| 100 | |
| 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 | |
| 106 | ============================================================================== |
| 107 | 3. LogiPat History *logipat-history* |
| 108 | |
| 109 | v3 Sep 25, 2006 * LP_Or() fixed; it now encapsulates its output |
| 110 | in \%(...\) parentheses |
| 111 | Dec 12, 2011 * |:ELP| added |
| 112 | * "" is mapped to a single " and left inside patterns |
| 113 | v2 May 31, 2005 * LPF and LogiPatFlags commands weren't working |
| 114 | v1 May 23, 2005 * initial release |
| 115 | |
| 116 | ============================================================================== |
| 117 | vim:tw=78:ts=8:ft=help |