machakann / vim-sandwich

Set of operators and textobjects to search/select/edit sandwiched texts.
1.43k stars 38 forks source link

Search next match on line if cursor not within surrounding #92

Open rattletat opened 4 years ago

rattletat commented 4 years ago

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.

ahmadie commented 3 years ago

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

ahmadie commented 3 years ago

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 (operator-sandwich-delete)A nmap sr (operator-sandwich-replace)A ``

astier commented 1 year ago

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 commented 1 year ago

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