-
Notifications
You must be signed in to change notification settings - Fork 0
/
vim-regex.txt
executable file
·83 lines (72 loc) · 3.46 KB
/
vim-regex.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
# vim normal-mode regex, in re2vba.pl input format.
# Copyright (c) Chris White 2018--2019.
# CC-BY-NC-SA 4.0, or any later version, at your option.
# Useful command line:
# ./re2vba.pl --nodim vim-regex.txt |tee >(putclip)
# Note: normal-mode commands defined by Vim but available to be
# repurposed by VimWord: at least Q (no Ex mode), U (Word doesn't
# save undo information per line).
# Main pattern
main ^(
(\"(?<register>[0-9a-z]))?
(?<spaceone>[ ]?)
(?<count1>[1-9][0-9]*)?
(?:
(?<spacetwo>[ ]?)
(?<=intrans)
|(?<=trans)
|(?<=trans-abbr)
)
)$
# not in Vim:
# <Space> in <space-one> or <space-two> (or both; no cumulative
# effect) applied with an operator that will cause the motion to
# extend to include any further inline whitespace. E.g., <Space>df,
# will delete to the following comma, and delete any spaces or tabs
# after that comma. Likewise, <Space>db will delete one word
# backwards, and any inline whitespace before that word.
# Motions that don't take arguments (although they may take counts).
# A motion of "0" is special-cased in the parsing code to keep the regex
# clean. This regex, after backtracking, matches "10" as a count of "1"
# followed by a "0" motion. We special-case rather than handling that here.
noarg-motion [HMLG
hjkl
wbWB
\x28\x29\x7b\x7d]|
(?# 28/29 are parens, move sentence )
(?# 7b/7d are braces, move paragraph )
g?[eE0\^\$]| (?# gw, gb, etc. are not motions.)
(?# ^ Note: 0 is special-cased in the parsing code.)
\x0d (?# <CR> at the end = "Current MS Word selection")
# Intransitive, including motions. These can take a count, namely ?<count1>.
intrans (?<iverb>
(?<imotion> (?# motions)
(?<=noarg-motion)|
[fFtT](?<itext>.)
)|
(gW)?g?[\*#]| (?# searches)
g?[pP] (?# pastes)
)
# IVERB: what to do
# ITEXT: character to jump to
# Text-object selection ([ai][something])
# Difference from Vim: B (block) is delimited by ^p^p. `{` and `}` are still
# available for brace-delimited blocks.
textobj (?<ninja>[\[\]])? (?# Ninja-feet marker)
# https://github.com/tommcdo/vim-ninja-feet
(?<tobj_range>[ai]) (?# Introducer)
(?<objtype>[wWspB]) (?# Type of text object)
# Transitive: verb, count, object, object type, text
trans (?<tverb>[cdyvX]) (?# TVERB: what to do)
(?<count2>[1-9][0-9]*)? (?# Count after the operator)
(?<target> (?# What to work on)
(?<=textobj)| (?# Text objects)
[fFtT](?<ttext>.)| (?# Motions with an argument)
(?<=noarg-motion) (?# Motions without an arg)
)
# Transitive abbreviations: x, ., ... . These are the end of the entry ---
# nothing comes after them.
# Note: I have repurposed `X` as delete-without-yank, so it is no longer
# a synonym for `dh`.
trans-abbr (?<tverbabbr>[x\.])
# vi: set ts=4 sts=4 sw=4 et ai ff=unix ft=sh: #