]> git.madduck.net Git - etc/vim.git/blob - doc/explainpat.txt

madduck's git repository

Every one of the projects in this repository is available at the canonical URL git://git.madduck.net/madduck/pub/<projectpath> — see each project's metadata for the exact URL.

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.

SSH access, as well as push access can be individually arranged.

If you use my repositories frequently, consider adding the following snippet to ~/.gitconfig and using the third clone URL listed for each project:

[url "git://git.madduck.net/madduck/"]
  insteadOf = madduck:

afe0fc9883a9b6cc246a8decb7e34632a167a277
[etc/vim.git] / doc / explainpat.txt
1 *explainpat.txt*    Give detailed help on a regexp pattern.
2
3                     For Vim version 7.0.  Last change: 2017 Oct 20
4                     By Andy Wokula <anwoku@yahoo.de>
5
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.
10
11 If you find that it explains something wrong, please drop me an email.
12
13 URL http://vim.sourceforge.net/scripts/script.php?script_id=4364
14 ==============================================================================
15                                                 *:ExplainPattern*
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.
21
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
26                                 etc.
27
28 Notes:
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.
32
33 :ExplainPattern also accepts some invalid patterns: >
34         :ExplainPattern \)
35         Pattern: \)
36         \)         end of group
37
38 ==============================================================================
39 TODO:
40
41 Ideas:
42 - If the user already knows regular expressions but of a different kind,
43   explain items in that different language.
44   Other regexp idioms:
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"
52
53 ==============================================================================
54 History:
55
56 v0.7
57 + BF `\{3,4\}` not accepted, only `\{3,4}`
58
59 v0.6
60 + BF `[]` is a literal string (not a collection)
61
62 v0.5
63 + BF `$\n^`
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
67   export HTML etc.)
68
69 v0.4
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`, ...
74
75 v0.3
76 + BF accept `\z(...\)` and `\z[N]`
77 + BF accept `[=a=]` and `[.a.]` in collections
78
79 v0.2
80 + include vim_use suggestions [2012 Dec 19]
81   * for collections [^...], add "not matching [...]"
82   * fix `\%>'a1`
83   * more detailed `\%x31`
84
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
89 + `\%[...]`
90 + `\{`, `\{-`
91
92 ==============================================================================
93 vim:tw=78:fo=tcq2:sts=0:ts=8:sw=8:fdm=marker:fmr=^_\^,^\^:ft=help: