aboutsummaryrefslogtreecommitdiffstats
path: root/doc/textobj.txt
blob: fdd035f59bf4d3631bbe6a12f62bde7f6dc7b119 (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
*textobj.txt*  Allows configuration of custom text objects

Author:  Jesse Luehrs <https://tozt.net/>
License: MIT

=============================================================================
OVERVIEW                                                   *textobj-overview*

This plugin allows configuration of custom |text-objects|, to perform actions
on additional sections of text than Vim has built-in.

=============================================================================
CONFIGURATION                                         *textobj-configuration*

Configuration is done by setting the `g:textobj_defs` variable to a |dict|
which maps input keys to a list containing the text object type and arguments
to pass to that type. For instance:

>
    let g:textobj_defs = {
    \    '/': ['paired'],
    \    'r': ['paired', '/'],
    \    '\|': ['paired'],
    \    'f': ['fold'],
    \    ',': ['arg'],
    \}
<

This defines five text object characters: `/` and `r` (for regex?) for text
within matching pairs of `/` characters, `|` for text within matching pairs of
`|` characters, `f` for text within the current fold, and `,` for the current
argument in a comma-separated function argument list. This, for instance,
allows you to use `di/` to delete the text within a Perl regex.

Currently, these are the available types:

                                                           *textobj-paired*
* `paired`: matches text between pairs of characters. Takes one optional
  argument for the character to match between, which defaults to the input
  character.

                                                             *textobj-fold*
* `fold`: matches the text within the current fold. Takes no arguments.

                                                              *textobj-arg*
* `arg`: matches the current function argument. Given text like
  `foo(bar, b|az, quux)` (where `|` is the cursor location), if `,` is the
  input character, `da,` will result in `foo(bar, |quux)` and `di,` will
  result in `foo(bar, |, quux)` . Takes no arguments.

 vim:tw=78:et:ft=help:norl: