How do you write recipe for all quotes types + miscellaneous characters?
Closed this issue · 1 comments
I'm using vim-surround mapping.
I would like to implement something like
viq
ciq
diq
caq
daq
csq
dsq
mapping to change or delete any quote marks including '
"
or backtick.
*** I don't mind about ysiwq
as it won't know which quote i mean.
Example : "'Text'"
viq
= visually selects =>'Text'
ciq
=>"'(ready to type)'"
diq
=>"''"
caq
=>"(ready to type)"
daq
=>""
csq(
=>"(Text)"
dsq
=>"Text"
I was searching through the web and the doc but all I could find was this example:
let g:sandwich#recipes += [
\ {
\ 'buns': ["[`'\"]\s*", "\s*[`'\"]"],
\ 'regex': 1,
\ 'input' : ['q'],
\ },
\ ]
However, the above example doesn't work as intended.
I think the documentation should have a few more examples on how to implement simple mappings (for example q
in this case) to whatever you would like to surround with.
Also I have had this in my .vimrc for a long time, and now since vim-sandwich allows customising, I wanted to implement this in input of a
.
for char in [ '_', '.', ':', ',', ';', '<bar>', '/', '<bslash>', '*', '+', '-', '#' ]
execute 'xnoremap i' . char . ' :<C-u>normal! T' . char . 'vt' . char . '<CR>'
execute 'onoremap i' . char . ' :normal vi' . char . '<CR>'
execute 'xnoremap a' . char . ' :<C-u>normal! F' . char . 'vf' . char . '<CR>'
execute 'onoremap a' . char . ' :normal va' . char . '<CR>'
endfor
Basically, I would like to have similar functionality (e.g. cia
dia
csa
dsa
etc.) to recognise all of '_', '.', ':', ',', ';', '<bar>', '/', '<bslash>', '*', '+', '-', '#'
as a
. (Or anything else like o
or x
or whatever)
For example : THIS_IS_A|_NAME
(cursor represented as |
)
cia
=>THIS_IS_(ready to type)_NAME
dia
=>THIS_IS__NAME
daa
=>THIS_ISNAME
- etc.
What would be the simplest way to implement these?