All patches and comments are welcome. Please squash your changes to logical
commits before using git-format-patch and git-send-email to
patches@git.madduck.net.
If you'd read over the Git project's submission guidelines and adhered to them,
I'd be especially grateful.
1 *explainpat.txt* Give detailed help on a regexp pattern.
3 For Vim version 7.0. Last change: 2017 Oct 20
4 By Andy Wokula <anwoku@yahoo.de>
6 *explainpat* *explainpat.vim*
7 ExplainPat is a plugin to inspect a Vim regexp pattern and show a line of help
8 for each found regexp item. Purpose is to get a better view on somebody
9 else's complex regexp string. It may also help with spotting mistakes.
11 If you find that it explains something wrong, please drop me an email.
13 URL http://vim.sourceforge.net/scripts/script.php?script_id=4364
14 ==============================================================================
16 :ExplainPattern {pattern}
17 :ExplainPattern {register}
18 inspect the given Vim {pattern} and print a line of
19 help (with color) for each found pattern item. Nested
20 items get extra indent.
22 A single-char argument is used as {register} argument:
23 / explain the last search pattern
24 * explain pattern from the clipboard
25 a explain pattern from register a
29 The pattern is first converted into a purely |magic| pattern using
30 |nwo#magic#MakeMagic()|. This means that embedded |/\V| |/\M| |/\m| |/\v|
31 specifiers are effectively removed from the explanation.
33 :ExplainPattern also accepts some invalid patterns: >
38 ==============================================================================
42 - If the user already knows regular expressions but of a different kind,
43 explain items in that different language.
45 Perl, Python, Emacs, Java, C#, Sed, Grep;
46 Vim ... very magic, nomagic, very nomagic
47 Possible config var name:
48 g:explainpat_user_knows = "Perl"
49 g:explainpat_background = "Perl"
50 g:explainpat_in_terms_of = "Perl"
51 g:explainpat_language = "Perl"
53 ==============================================================================
57 + BF `\{3,4\}` not accepted, only `\{3,4}`
60 + BF `[]` is a literal string (not a collection)
64 + wording: `\|` is not an "OR branch" (it separates or branches)
65 + NF added tests (not part of release)
66 + NF accept custom help printer (for testing purpose, could also be used to
70 + BF `[foo` is a literal string
71 + BF for |/star|, |/^| and |/$|, distinguish position in the pattern
72 (sometimes these become literal); special cases: `^**`, `^^`, `\c^^`, `$$`,
73 `a\|^b`, `a\&*b`, `[ab`, `\_[ab`, ...
76 + BF accept `\z(...\)` and `\z[N]`
77 + BF accept `[=a=]` and `[.a.]` in collections
80 + include vim_use suggestions [2012 Dec 19]
81 * for collections [^...], add "not matching [...]"
83 * more detailed `\%x31`
85 v0.1 (initial version)
86 + start of "first" capturing group, start of 2nd ...
87 + `\|` should get less indent than the branches, do we need to create an
88 AST? ! no, keep it straight forward
92 ==============================================================================
93 vim:tw=78:fo=tcq2:sts=0:ts=8:sw=8:fdm=marker:fmr=^_\^,^\^:ft=help: