sponsor Vim development Vim logo Vim Book Ad

ExplainPattern : Give detailed help on a given regexp pattern.

 script karma  Rating 7/4, Downloaded by 344    Comments, bugs, improvements  Vim wiki

created by
Andy Wokula
 
script type
utility
 
description
:ExplainPattern {pattern}               or
:ExplainPattern {register}

        parse the given Vim {pattern} and print a line of help
        (with color) for each found pattern item.  Nested
        items get extra indent.

        A single-char argument is used as {register} argument:
                / explain the last search pattern
                * explain pattern from the clipboard
                a explain pattern from register a


Example:  :ExplainPattern *

Register: *
Pattern: \C^\%(\\\%(@<.\|%[dxouU[(^$V#<>]\=\|z[1-9se(]\|@[>=!]\|_[[^$.]\=\|.\)\|.\)
  \C         match case while matching the pattern
  ^          match at start of line (or string)
  \%(        start of non-capturing group
  |   \\         literal string (1 atom(s))
  |   \%(        start of non-capturing group
  |   |   @<         literal string (2 atom(s))
  |   |   .          match any character
  |   | \|         OR branch
  |   |   %          literal string (1 atom(s))
  |   |   [dxouU[(^$V#<>] collection
  |   |   \=         (multi) zero or one of the preceding atom
  |   | \|         OR branch
  |   |   z          literal string (1 atom(s))
  |   |   [1-9se(]   collection
  |   | \|         OR branch
  |   |   @          literal string (1 atom(s))
  |   |   [>=!]      collection
  |   | \|         OR branch
  |   |   _          literal string (1 atom(s))
  |   |   [[^$.]     collection
  |   |   \=         (multi) zero or one of the preceding atom
  |   | \|         OR branch
  |   |   .          match any character
  |   \)         end of group
  | \|         OR branch
  |   .          match any character
  \)         end of group

2013 Jan 17
 
install details
This is a vimball archive, edit it in vim, do  :so %   , then restart.
 

rate this script Life Changing Helpful Unfulfilling 
script versions (upload new version)

Click on the package to download.

package script version date Vim version user release notes
explainpat_0.5.vmb 0.5 2013-03-09 7.0 Andy Wokula Bug fixes (accept more patterns): `\z(', `\z1', ..., `[foo'; added cases where `^', `*', `$' become literal; `[=a=]` in collections, a few more.
explainpat_0.2.vmb 0.2 2012-12-19 7.0 Andy Wokula include suggestions from vim_use
explainpat_0.1.vmb 0.1 2012-12-19 7.0 Andy Wokula Uploaded again, this time not gzipped (vimball anyway keeps an unpacked version on disk)
ip used for rating: 23.22.97.26

If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to the maillist. Help Bram help Uganda.
   
SourceForge.net Logo