machakann / vim-sandwich

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

How to omit last parameter? #146

Closed singlexyz closed 2 years ago

singlexyz commented 2 years ago

Normally, to use the add function, I would use saiw' to add single quotes to the current word.

But if I want to simply use 'iw to implement, I can omit some keys.

That is, I mapped ' to <Plug>(sandwich-add), But I still have to press 'iw'.

nmap ' <Plug>(sandwich-add)

In other words, I want to change the order of the key press, enter the surrounding first, then enter the textobj.

machakann commented 2 years ago

Probably, you can use <Plug>(operator-sandwich-add-query1st) instead of <Plug>(sandwich-add)? I personally use the mappings below.

nmap s' <Plug>(operator-sandwich-add-query1st)'
xmap s' <Plug>(operator-sandwich-add)'
singlexyz commented 2 years ago

Probably, you can use <Plug>(operator-sandwich-add-query1st) instead of <Plug>(sandwich-add)? I personally use the mappings below.

nmap s' <Plug>(operator-sandwich-add-query1st)'
xmap s' <Plug>(operator-sandwich-add)'

Yeah, that's it. This saves a lot of keys.

nnoremap ' <Plug>(operator-sandwich-add-query1st)'
nnoremap ` <Plug>(operator-sandwich-add-query1st)`
nnoremap " <Plug>(operator-sandwich-add-query1st)"
nnoremap ( <Plug>(operator-sandwich-add-query1st)(
nnoremap [ <Plug>(operator-sandwich-add-query1st)[
nnoremap { <Plug>(operator-sandwich-add-query1st){