Wim - Capture Between a Slash?

Is there a way to move text between /or \? I know that there are movements for other characters ---

ci" - Capture the "text" inside "text"

vi(- visual capture int varinsidefoo(int var)

di[- Delete word [word]in[]

The only workaround I can find is to use Vim Surround and use it to change the environment \to "( cs\") and then from there. However, this is not only tedious, but the plugin supports backslash, not forward.

+4
source share
4 answers

.

onoremap <silent> i/ :<C-U>normal! T/vt/<CR> " inside /
onoremap <silent> a/ :<C-U>normal! F/vf/<CR> " around /

:

xnoremap <silent> i/ :<C-U>normal! T/vt/<CR> " inside /
xnoremap <silent> a/ :<C-U>normal! F/vf/<CR> " around /

\

: .

+7

:

  nnoremap H mal??e+1<Enter>mb//<Enter>y`b`a

.

.vimrc , .

:

  • : /\/ ( )
  • ( )
  • H

, / /, .

:

  nnoremap H mal??e+1<Enter>mb//<Enter>y`b`a

 - nnoremap H      map H in normal mode, ignoring other mappings    
 - ma              place a mark (named a) at the current cursor location
 - l               move the cursor one char to the right
 - ??e+1<Enter>    move to 1 character after END of prev occurrence of last search pattern
 - mb              place a mark (named b) at the current cursor location
 - //<Enter>       go to the beginning of the next occurrence of the last search pattern
 - y`b             yank to the location of the mark named x (note: ` = "back tick")
 - `a              go to the mark named `a`

:

This is a *funky* string
  • *
  • ( )
  • H

funky yank.

!

:

<br>
Capture all this text.
<br>
  • <br>
  • H , <br> ( 2- <br>)

!

:

<p>
Capture this paragraph.
</p>
  • <.\?p> ( <\/\{,1}p>).
  • H , ( <p>)

...

, / . , / \ <\?p> .

+3

slash. , , : targets

+2

Source: https://habr.com/ru/post/1540603/


All Articles