The textobj for between 2 characters.
(||
is cursor.)
abXc|d|eYgh
You can press v
(to visual mode) and a2XY
to select XcdeY
.
(vim-textobj-twochars depends on vim-textobj-user.)
dein
call dein#add('utubo/vim-textobj-twochars')
Default is a2
and i2
.
Example: (Mapping to aX
and iX
.)
call textobj#user#map('twochars', {'-': {'select-a': 'aX', 'select-i': 'iX'}})
let g:textobj_twochars_select_on_cursor_line=1
Select on cursor line.
Example1:
hello world
|h|ello world
You can press va2eo
to select ello
.
Example2:
hello world
hello wo|r|ld
You can press va2lo
to select lo wo
.
- vim-textobj-twochars does not support a nested pair.
- When press same characters on the cursor, vim-textobj-twochars searches the tail from
- In the current line and after the cursor
- In the current line and before the cursor
- After the current line
Exmaple1:
set $a = "abc|"|;
set $b = "xyz";
You can press va2""
to select "abc"
.
Exmaple2:
set $a = "abc"; set $b = @|"|
hello world
";
You can press va2""
to select "; set $b = @"
.
Mapping A2
and I2
to select on the cursorline,
and a2
and i2
to select on multiline mode.
let g:textobj_twochars_select_on_cursor_line=0
call textobj#user#plugin('twocharscursorline', {
\ '-': {
\ 'select-a': 'A2',
\ 'select-a-function': 'textobj#twochars#select_a_cursorline',
\ 'select-i': 'I2',
\ 'select-i-function': 'textobj#twochars#select_i_cursorline',
\ },
\ })
Mapping a2
and i2
to select on the cursorline,
and A2
and I2
to select on multiline mode.
let g:textobj_twochars_select_on_cursor_line=1
call textobj#user#plugin('twocharsmultiline', {
\ '-': {
\ 'select-a': 'A2',
\ 'select-a-function': 'textobj#twochars#select_a_multiline',
\ 'select-i': 'I2',
\ 'select-i-function': 'textobj#twochars#select_i_multiline',
\ },
\ })
Released under the MIT license.
Copyright 2020 utubo