aboutsummaryrefslogtreecommitdiff
path: root/doc/regex_escape.txt
blob: 1377fcdd521675f9bf13b4a91a043ed98a9d8b74 (plain) (blame)
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
*regex_escape.txt*	For Vim version 7.0	Last change: 2018 Dec 29

DESCRIPTION				*regex_escape*

This plugin provides normal and visual mode mapping targets to insert escaping
backslash characters before regular expression metacharacters for text
selected by a motion, as a quick way to put a literal string into a regular
expression context.

It's useful generally as a shortcut, but the author particularly likes it for
keeping track of backslash-heavy expressions where counting gets tiresome.

For example, in the default BRE mode, this string: >
   foo * ^bar $\ baz \ quux
Becomes: >
   foo \* \^bar \$\\ baz \\ quux

OPTIONS					*regex_escape-options*

					*b:regex_escape_flavor*
Set `b:regex_escape_flavor` to one of "bre", "ere", or "vim", to choose a
regex flavor for a particular buffer.  It might be a good idea to set (and
clear) this in filetype plugins.

					*g:regex_escape_flavor*
Set `g:regex_escape_flavor` to one of "bre", "ere", or "vim", to choose a
default global regex flavor for any buffer where `b:regex_escape_flavor` is
not set.

If neither of these options are set, "bre" is used.

The ERE class includes / as a character, just because it's always the
delimiter in AWK, and so often (but not always) the delimiter in Perl.  This
may mean that slash gets escaped unnecessarily in Perl patterns, and possibly
anywhere you use ERE outside of AWK.

The Vim set assumes 'magic', just because the author never messes with that.
You might like to add e.g. "vim_magic", "vim_nomagic" etc classes if that
matters to you.

REQUIREMENTS				*regex_escape-requirements*

This plugin only loads if 'compatible' is not set.

MAPPINGS				*regex_escape-mappings*

					*<Plug>(RegexEscape)*
The normal and visual mode mapping targets are both named
|<Plug>(RegexEscape)|.  There are no default key mappings; you should define
one yourself in your |vimrc|.  For example:
>
	nmap <Leader>\ <Plug>(ReplaceOperator)
	xmap <Leader>\ <Plug>(ReplaceOperator)
<
AUTHOR					*regex_escape-author*

Written and maintained by Tom Ryder <tom@sanctum.geek.nz>.

LICENSE					*regex_escape-license*

Licensed for distribution under the same terms as Vim itself (see |license|).

 vim:tw=78:ts=8:ft=help:norl: