vim-sandwich icon indicating copy to clipboard operation
vim-sandwich copied to clipboard

Search next match on line if cursor not within surrounding

Open rattletat opened this issue 4 years ago • 4 comments

Hey I use targets.vim and vim-sandwich together.

I'm not sure whether this behavior is from vim itself or targets, but often you can just do something like this:

Test | Test Test ( More Text )

| is the cursor. One could press di) now and yield:

Test | Test Test ()

However, doing something like sd) is not possible atleast with my configuration. Is this achievable? This feature would make my vim operator experience more consistent.

rattletat avatar Mar 29 '20 17:03 rattletat

would be great if wellle/targets.vim could be used as text objects !!

ahmadie avatar Nov 25 '20 06:11 ahmadie

I was able to make work with following config :D

`` let g:sandwich_no_default_key_mappings = 1 let g:textobj_sandwich_no_default_key_mappings = 1

call plug#begin('~/.vim/plugged')

Plug 'machakann/vim-sandwich' Plug 'wellle/targets.vim' call plug#end()

nmap sd <Plug>(operator-sandwich-delete)A nmap sr <Plug>(operator-sandwich-replace)A ``

ahmadie avatar Nov 28 '20 03:11 ahmadie

I needed to use

nmap sd <plug>(operator-sandwich-delete)a
nmap sr <plug>(operator-sandwich-replace)a
nmap sa <plug>(operator-sandwich-add)
xmap sa <plug>(operator-sandwich-add)

Another benefit seems to be that its possible now to use targets builtin objects like q.

astier avatar Mar 04 '23 13:03 astier

Sadly it seems to break the magic character f. To make it work I had to add additionally:

nmap sdf <plug>(sandwich-delete)f
nmap srf <plug>(sandwich-replace)f

astier avatar Mar 07 '23 21:03 astier