Skip to content

Commit 97801be

Browse files
authored
Merge pull request #258 from mnishz/pattern_for_Vim_8.1
Update pattern from Vim 8.0 to 8.1
2 parents d26653f + d7f88a1 commit 97801be

File tree

2 files changed

+74
-44
lines changed

2 files changed

+74
-44
lines changed

doc/pattern.jax

Lines changed: 38 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
*pattern.txt* For Vim バージョン 8.0. Last change: 2017 Mar 05
1+
*pattern.txt* For Vim バージョン 8.1. Last change: 2018 Mar 13
22

33

44
VIMリファレンスマニュアル by Bram Moolenaar
@@ -897,7 +897,7 @@ $ パターンの末尾、または "\|"、"\)"、"\n" ('magic' on時) の前に
897897
ります。Vim は自動的にマッチの強調表示を更新したりしません。
898898
|/\%#| で検索した後にカーソルを動かした場合と似ています。
899899

900-
*/\%l* */\%>l* */\%<l*
900+
*/\%l* */\%>l* */\%<l* *E951*
901901
\%23l 指定した行にマッチします。
902902
\%<23l 指定した行より上にマッチします。
903903
\%>23l 指定した行より下にマッチします。
@@ -1065,33 +1065,40 @@ x 特別な意味のない文字は、その文字自身とマッチします
10651065
ド全体がパターンとなることに注意してください。例えば、":s/[/x/" は
10661066
"[/x" を検索します。置換はおこなわれません。"[" を検索して "x" に置換
10671067
するのではありません!
1068+
1069+
*E944* *E945*
10681070
コレクション文字列の先頭が "^" の場合、コレクションに含まれている文字
10691071
以外の文字がマッチします。"[^xyz]" は 'x'、'y'、'z' 以外の文字にマッチ
10701072
します。
10711073
- 2 つの文字で '-' を挟んで、ASCII 文字の範囲を指定できます。たとえ
1072-
ば、"[0-9]" はすべての数字にマッチします。非ASCII 文字も指定できます
1073-
が 2 つの文字の値の差が 256 を超えてはなりません。
1074+
ば、"[0-9]" はすべての数字にマッチします。例えば [c-a] のように最初
1075+
の文字が後ろの文字よりも大きい場合は E944 が発生します。非ASCII 文字
1076+
も指定できますが、古い正規表現エンジンでは 2 つの文字の値の差が 256
1077+
を超えてはなりません。例えば re=1 をセットした後に [\u3000-\u4000]
1078+
で検索すると E945 が発生します。先頭に \%#=2 を追加することでこれを
1079+
回避できます。
10741080
- 文字クラス表現を使って、その文字クラスが含んでいる文字を取り込むこと
10751081
ができます。次の文字クラスがサポートされています。
1076-
名前 含んでいるもの ~
1077-
*[:alnum:]* [:alnum:] ASCII の英数字
1078-
*[:alpha:]* [:alpha:] ASCII の英字
1079-
*[:blank:]* [:blank:] スペースと Tab 文字
1080-
*[:cntrl:]* [:cntrl:] コントロール文字
1081-
*[:digit:]* [:digit:] 10 進数字
1082-
*[:graph:]* [:graph:] スペース以外の印字可能文字
1083-
*[:lower:]* [:lower:] 小文字英字 ('ignorecase' がオンのとき
1082+
名前 関数 含んでいるもの ~
1083+
*[:alnum:]* [:alnum:] isalnum ASCII の英数字
1084+
*[:alpha:]* [:alpha:] isalpha ASCII の英字
1085+
*[:blank:]* [:blank:] スペースとタブ
1086+
*[:cntrl:]* [:cntrl:] iscntrl ASCII コントロール文字
1087+
*[:digit:]* [:digit:] 10 進数字、'0' から '9'
1088+
*[:graph:]* [:graph:] isgraph スペース以外の ASCII 印字可能文字
1089+
*[:lower:]* [:lower:] (1) 小文字英字 ('ignorecase' がオンのとき
10841090
はすべての英字)
1085-
*[:print:]* [:print:] スペースを含む印字可能文字
1086-
*[:punct:]* [:punct:] ASCII の句読点
1087-
*[:space:]* [:space:] 空白文字 (スペース、Tab、改ページ文字)
1088-
*[:upper:]* [:upper:] 大文字英字 ('ignorecase' がオンのとき
1091+
*[:print:]* [:print:] (2) スペースを含む印字可能文字
1092+
*[:punct:]* [:punct:] ispunct ASCII の句読点
1093+
*[:space:]* [:space:] 空白文字: スペース、タブ、復帰コード、
1094+
改行コード、垂直タブ、改ページ
1095+
*[:upper:]* [:upper:] (3) 大文字英字 ('ignorecase' がオンのとき
10891096
はすべての英字)
1090-
*[:xdigit:]* [:xdigit:] 16 進数字
1091-
*[:return:]* [:return:] <CR> 文字
1092-
*[:tab:]* [:tab:] <Tab> 文字
1093-
*[:escape:]* [:escape:] <Esc> 文字
1094-
*[:backspace:]* [:backspace:] <BS> 文字
1097+
*[:xdigit:]* [:xdigit:] 16 進数字: 0-9, a-f, A-F
1098+
*[:return:]* [:return:] <CR> 文字
1099+
*[:tab:]* [:tab:] <Tab> 文字
1100+
*[:escape:]* [:escape:] <Esc> 文字
1101+
*[:backspace:]* [:backspace:] <BS> 文字
10951102
角カッコで囲んだ文字クラス表現を、コレクションの角カッコ内に書きま
10961103
す。たとえば、"[-./[:alnum:]_~]\+" は、UNIX のファイル名として妥当な
10971104
パターンです。このパターンは、'-'、'.'、'/'、英数字、'_'、'~'、のど
@@ -1101,6 +1108,13 @@ x 特別な意味のない文字は、その文字自身とマッチします
11011108
文字にも作用します。|two-engines| を参照。将来的にはこれらの項目は、
11021109
マルチバイト文字に作用するようになるでしょう。現状 "alpha" の全てを
11031110
得るには [[:lower:][:upper:]] を使う事ができます。
1111+
1112+
"関数" 列はどのライブラリ関数が使われるかを示しています。実装はシス
1113+
テムに依存します。特殊なものは以下の通りです:
1114+
(1) ASCII には islower()、それ以外には、|+multi_byte| 機能付きでビル
1115+
ドされた場合 Vim の組み込みルールが使用されます。
1116+
(2) Vim の組み込みルールが使用されます。
1117+
(3) (1)と同じですが、代わりに isupper() が使用されます。
11041118
*/[[=* *[==]*
11051119
- 等価クラス。これはその文字とほぼ同じ文字にマッチします。例えば、アク
11061120
セントを無視するなど。これは Unicode、latin1、latin9 でのみ機能しま
@@ -1142,7 +1156,9 @@ x 特別な意味のない文字は、その文字自身とマッチします
11421156
- コレクションを使ったマッチングは遅くなることがあります。コレクション
11431157
の文字と、テキストの文字を、それぞれ 1 文字ずつ比較する必要があるか
11441158
らです。同じ意味のアトムが他にある場合は、それを使ってください。たと
1145-
えば、"\d" は "[0-9]" よりも速く、同じ文字にマッチします。
1159+
えば、"\d" は "[0-9]" よりも速く、同じ文字にマッチします。ただし新し
1160+
|NFA| 正規表現エンジンにおけるこれらの取り扱いは、古いものよりも
1161+
高速です。
11461162

11471163
*/\%[]* *E69* *E70* *E369*
11481164
\%[] 任意にマッチするアトム列です。これは常にマッチします。アトム単位で最長

en/pattern.txt

Lines changed: 36 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
*pattern.txt* For Vim version 8.0. Last change: 2017 Mar 05
1+
*pattern.txt* For Vim version 8.1. Last change: 2018 Mar 13
22

33

44
VIM REFERENCE MANUAL by Bram Moolenaar
@@ -905,7 +905,7 @@ $ At end of pattern or in front of "\|", "\)" or "\n" ('magic' on):
905905
becomes invalid. Vim doesn't automatically update the matches.
906906
Similar to moving the cursor for "\%#" |/\%#|.
907907

908-
*/\%l* */\%>l* */\%<l*
908+
*/\%l* */\%>l* */\%<l* *E951*
909909
\%23l Matches in a specific line.
910910
\%<23l Matches above a specific line (lower line number).
911911
\%>23l Matches below a specific line (higher line number).
@@ -1076,34 +1076,40 @@ x A single character, with no special meaning, matches itself
10761076
":s/[/x/" searches for "[/x" and replaces it with nothing. It does
10771077
not search for "[" and replaces it with "x"!
10781078

1079+
*E944* *E945*
10791080
If the sequence begins with "^", it matches any single character NOT
10801081
in the collection: "[^xyz]" matches anything but 'x', 'y' and 'z'.
10811082
- If two characters in the sequence are separated by '-', this is
10821083
shorthand for the full list of ASCII characters between them. E.g.,
1083-
"[0-9]" matches any decimal digit. Non-ASCII characters can be
1084-
used, but the character values must not be more than 256 apart.
1084+
"[0-9]" matches any decimal digit. If the starting character exceeds
1085+
the ending character, e.g. [c-a], E944 occurs. Non-ASCII characters
1086+
can be used, but the character values must not be more than 256 apart
1087+
in the old regexp engine. For example, searching by [\u3000-\u4000]
1088+
after setting re=1 emits a E945 error. Prepending \%#=2 will fix it.
10851089
- A character class expression is evaluated to the set of characters
10861090
belonging to that character class. The following character classes
10871091
are supported:
1088-
Name Contents ~
1089-
*[:alnum:]* [:alnum:] ASCII letters and digits
1090-
*[:alpha:]* [:alpha:] ASCII letters
1091-
*[:blank:]* [:blank:] space and tab characters
1092-
*[:cntrl:]* [:cntrl:] control characters
1093-
*[:digit:]* [:digit:] decimal digits
1094-
*[:graph:]* [:graph:] printable characters excluding space
1095-
*[:lower:]* [:lower:] lowercase letters (all letters when
1092+
Name Func Contents ~
1093+
*[:alnum:]* [:alnum:] isalnum ASCII letters and digits
1094+
*[:alpha:]* [:alpha:] isalpha ASCII letters
1095+
*[:blank:]* [:blank:] space and tab
1096+
*[:cntrl:]* [:cntrl:] iscntrl ASCII control characters
1097+
*[:digit:]* [:digit:] decimal digits '0' to '9'
1098+
*[:graph:]* [:graph:] isgraph ASCII printable characters excluding
1099+
space
1100+
*[:lower:]* [:lower:] (1) lowercase letters (all letters when
10961101
'ignorecase' is used)
1097-
*[:print:]* [:print:] printable characters including space
1098-
*[:punct:]* [:punct:] ASCII punctuation characters
1099-
*[:space:]* [:space:] whitespace characters
1100-
*[:upper:]* [:upper:] uppercase letters (all letters when
1102+
*[:print:]* [:print:] (2) printable characters including space
1103+
*[:punct:]* [:punct:] ispunct ASCII punctuation characters
1104+
*[:space:]* [:space:] whitespace characters: space, tab, CR,
1105+
NL, vertical tab, form feed
1106+
*[:upper:]* [:upper:] (3) uppercase letters (all letters when
11011107
'ignorecase' is used)
1102-
*[:xdigit:]* [:xdigit:] hexadecimal digits
1103-
*[:return:]* [:return:] the <CR> character
1104-
*[:tab:]* [:tab:] the <Tab> character
1105-
*[:escape:]* [:escape:] the <Esc> character
1106-
*[:backspace:]* [:backspace:] the <BS> character
1108+
*[:xdigit:]* [:xdigit:] hexadecimal digits: 0-9, a-f, A-F
1109+
*[:return:]* [:return:] the <CR> character
1110+
*[:tab:]* [:tab:] the <Tab> character
1111+
*[:escape:]* [:escape:] the <Esc> character
1112+
*[:backspace:]* [:backspace:] the <BS> character
11071113
The brackets in character class expressions are additional to the
11081114
brackets delimiting a collection. For example, the following is a
11091115
plausible pattern for a UNIX filename: "[-./[:alnum:]_~]\+" That is,
@@ -1114,6 +1120,13 @@ x A single character, with no special meaning, matches itself
11141120
regexp engine. See |two-engines|. In the future these items may
11151121
work for multi-byte characters. For now, to get all "alpha"
11161122
characters you can use: [[:lower:][:upper:]].
1123+
1124+
The "Func" column shows what library function is used. The
1125+
implementation depends on the system. Otherwise:
1126+
(1) Uses islower() for ASCII and Vim builtin rules for other
1127+
characters when built with the |+multi_byte| feature.
1128+
(2) Uses Vim builtin rules
1129+
(3) As with (1) but using isupper()
11171130
*/[[=* *[==]*
11181131
- An equivalence class. This means that characters are matched that
11191132
have almost the same meaning, e.g., when ignoring accents. This
@@ -1153,7 +1166,8 @@ x A single character, with no special meaning, matches itself
11531166
- Matching with a collection can be slow, because each character in
11541167
the text has to be compared with each character in the collection.
11551168
Use one of the other atoms above when possible. Example: "\d" is
1156-
much faster than "[0-9]" and matches the same characters.
1169+
much faster than "[0-9]" and matches the same characters. However,
1170+
the new |NFA| regexp engine deals with this better than the old one.
11571171

11581172
*/\%[]* *E69* *E70* *E369*
11591173
\%[] A sequence of optionally matched atoms. This always matches.

0 commit comments

Comments
 (0)