/
README
197 lines (166 loc) · 9.76 KB
/
README
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
*reggie_to.txt* For Vim version 7.0 Last change: 2011 February 22
xxxxx xxx ~
xxxxxx x xx x ~
xx x x xx xxx ~
x x x xx x ~
x x x ~
xx xx x xxx xxxx xxxx xxx xxx ~
xx xx x x xxx x xxx x x xxx x xxx x xxx ~
xx xxxx x xxx x xxxx x xxxx xx x xxx ~
xx xx xxx xx xxx xx xx xx xx xx xx xxx ~
xx xx xx xxxxxxxx xx xx xx xx xx xxxxxxxx ~
x xx xx xxxxxxx xx xx xx xx xx xxxxxxx ~
x xx xx xx xx xx xx xx xx ~
xxxx xxx xxxx x xx xx xx xx xx xxxx x ~
x xxxx xx xxxxxxx xxxxxxxx xxxxxxxx xxx x xxxxxxx ~
x xx x xxxxx xxx xxx xxx xxx xxx xxxxx ~
x xxx xxx ~
xx xxxx xxx xxxx xxx ~
xxxxxxx xx xxxxxxx xx ~
x xxxx x xxxx ~
Helping you tame those beasts!~
Reggie T.O.: RegExp Based Text Objects *reggie_to*
v1.0
This library allows to create regexp based text objects that follow the
behaviour of the built-in Vim text objects. It supports Ruby and VimL by
default.
==============================================================================
How to use it *reggie_to_use*
If your language of choice is not supported by default, you can create the
text objects (ik for inner and ak for all) for it. Create the file
ftplugin/[filetype]/reggie_to.vim somewhere in your 'runtimepath' ($HOME/.vim
is a usual place) and call reggie_to#init() after creating the following
variables as needed (see |reggie_to_example|):
b:reggie_to_start *b:reggie_to_start*
b:reggie_to_middle *b:reggie_to_middle*
b:reggie_to_end *b:reggie_to_end*
Value: string
Default: ""
These variables hold the patterns that will be used to match the start, middle
and end of the text object respectively. See |searchpair()|for more details.
Note: At least b:reggie_to_start and b:reggie_to_end must be set.
b:reggie_to_skip *b:reggie_to_skip*
Value: expression
Default: 0
This variable is used to skip over areas where it should not make sense to
match for the start/middle/end of a text objects. When this expression
evaluates to 1, the matched string will we skipped. See |searchpair()| for
more details.
b:reggie_to_map *b:reggie_to_map*
Value: string
Default: 'k'
The value of this variable is used to create the mappings by appending them to
i and a. e.g.: the default value of k will create the ik and ak text objects.
==============================================================================
Example *reggie_to_example*
We will create text objects to handle the following text:
>
1 if number of users == 1
2 send this to user
3 else
4 for every user in users
5 send this instead
6 send this multiline string "First line
7 end of indentation."
8 end
9 end
<
Let's say that the corresponding filetype for that language is "mine", so we
need to create the following file:
>
~/.vim/ftplugin/mine/reggie_to.vim
<
That file will be sourced when the 'filetype' option is set to "mine", so we
will set the variables and create the text objects using the following lines:
>
1 " Text objects start with 'if' and 'for' at the beginning of the line
2 " following 0 or more white spaces.
3 let b:reggie_to_start = '^\s*\zs\(if\|for\)'
4
5 " Middle of the text objects matches 'else' following 0 or more white
6 " space.
7 let b:reggie_to_middle = '^\s*\zselse'
8
9 " The end of the text objects matches 'end' following 0 or more white
10 " space.
11 let b:reggie_to_end = '^\s*\zsend'
12
13 " We don't like the default ik/ak mappings, so we'll use in/an.
14 let b:reggie_to_map = 'n'
15
16 " We should not match for limits of the text object inside strings or
17 " comments, the following expression returns 1 when evaluated with the
18 " cursor on a string or comment.
19 let b:reggie_to_skip =
20 \ 'synIDattr(synID(line("."),col("."),1),"name") =~? '.
21 \ '"comment\\|string"'
22
23 " Now let's create our beloved text objects.
24 call reggie_to#init()
<
Enjoy!
==============================================================================
Limitations *reggie_to_limitations*
- Works linewise.
- It might not work correctly or at all when any start/middle/end is part of a
multi statement line.
- Continued lines are not considered in inner text objects.
==============================================================================
Maintainer *reggie_to_maintainer*
Hi there! My name is Israel Chauca F. and I can be reached at:
mailto:israelchauca@gmail.com
Feel free to send me any feedback about this plugin, I'll be very pleased to
read it.
If you build a new ftplugin for a language, please send it to me and I'll add
it to the library.
==============================================================================
History *reggie_to_history*
Version Date Release notes ~
|------------------------------------------------------------------------------|
1.0 2011-02-22 * Current Release:
- Initial upload.
|------------------------------------------------------------------------------|
.-.._ ___ ~
,-' |:\ /'--.`. ~
/' ,|:|/::::| '\ ~
,' ,.-:::::::::::. \ ~
_/' /::::::::::::::::` \ ~
/' ':::::::_,--.::::::`.'\ ~
/ ,'::::.,-' `\::::::|| ~
| /:::_/' `\::::|| ~
| \::- \:::|| ~
/_ \_/ | ~
| '-._ / ~
|'. '`-..._ | ~
.. '--_ ''----.| ~
| `._ '----- '''----__,..\ ~
|.._ '-.._________..--' ,'|_ ~
| `--..__ _,' /| ''--. ~
''''''---..__ | '`-------''' /-\ .-.._\_ ~
'-\__ \-----....__ _..' ,.-. `. .`\ ~
'`. """--""" _/' _. \ \ | \ ~
\--..___ ___..-- / | ' | | \ ___...--- ~
_,........\ """--"" ./ |/-..__=..|,-' ~
______, '' ` __,...-'' ,' -.. ' ~
-' `.-...,-'''' - | '`---------- ~
\ _.,-'' .' ~
\ ..______.,-' ,' ~
'-. ,/' ~
''---'......-' ~
/`-._ ~
|::::""--.._ ~
/( )\ /::::::;;;;;\____ ~
\\ _ // /;;::::::;;;;;;;;;\ ~
_ / \(_)/ \ /;;;;:::::::;;;;;;;;\___ ~
/;| | < |;;;;;;;:::::::;;;;;;:::;\ ~
,-._/;;\ \_ / /;;;;;;;;;:::::::::::;;;;;;| ~
_.-;;::::;;;;\ / | /;;;;;:::::::::;;;:::::;;;;;;\ ~
/;;::;;;;;;;;;;\ | / _/;;;;::::::::::;;;;;:::::;;;;;;\ ~
_.-;::::::;;;;;;;;;;\ \__ \ /;;;;;:::::::::;;;;;::::;;;;;;;;;;\ ~
.-;;;::::::::::;;;;;;;;;\ `-' /;;;;:::::::::;;;;;;;;;::;;;;;;;;;;;\ ~
;;;;:::::::::::::;;;;;;;;| /;;;;;:::::;;;;;;;;;;;:::::;;;;;;;;JRO\~
Sand opened only two body lengths from him. Crystal teeth flashed in the dim~
light. He saw the yawning mouth-cavern with, far back, the ambient movement of~
dim flame. The overpowering redolence of the spice swept over him. But the ~
worm had stopped. ~
vim:tw=78:et:ts=8:sw=2:ft=help:norl:formatoptions+=tcroqn:autoindent: