Closed krishnakumarg1984 closed 3 years ago
@krishnakumarg1984 I also use sandwich
, and the commands sdc
, saac
, saic
, etc. already work for me. Does it not work for you?
Perhaps, you need to install the targets.vim
plugin as well for this to work (I already have it installed). Even without targets.vim
, most of the sandwich operators + vimtex text objects combinations work mostly fine, although I found that ic
doesn't really behave right. I'm not an expert on this, but :h g:vimtex_text_obj_variant
has some info.
Weirdly, I have only dsc
, dse
etc working. I will look at bit further into it when I start writing again this weekend.
Secondly, it is not clear from vimtex's
documentation that using sandwich
(with default mappings) shall automatically switch vimtex's
mappings from dsc
to sdc
, or from dse
to sde
etc.
The *s*
mappings are hard-coded everywhere in the documentation. For instance, in the mappings table:
dse |<plug>(vimtex-env-delete)| `n`
dsc |<plug>(vimtex-cmd-delete)| `n`
ds$ |<plug>(vimtex-env-delete-math)| `n`
dsd |<plug>(vimtex-delim-delete)| `n`
cse |<plug>(vimtex-env-change)| `n`
csc |<plug>(vimtex-cmd-change)| `n`
cs$ |<plug>(vimtex-env-change-math)| `n`
csd |<plug>(vimtex-delim-change-math)| `n`
tsf |<plug>(vimtex-cmd-toggle-frac)| `nx`
tsc |<plug>(vimtex-cmd-toggle-star)| `n`
tse |<plug>(vimtex-env-toggle-star)| `n`
tsd |<plug>(vimtex-delim-toggle-modifier)| `nx`
tsD |<plug>(vimtex-delim-toggle-modifier-reverse)| `nx`
And a few other places (towards the top of the help file, the README.md on GitHub etc). I suspect this is because the ds*
mappings are inspired by tpope's surround.vim which predates sandwich.vim by nearly 6-7 years, and the documentation just didn't get updated when sandwich support was added later on.
Hmm... I think I understand the situation a bit better now, sorry. There are several things which are subtly different. The first thing is the text objects ic/ac/ie/ae
, which you would use for example using saic
(but you could also do cic
, dic
, vic
or yic
for example). This is provided by vimtex.
The second thing is the explicit mappings which you mentioned, including dsc
. These are vimtex-specific, too.
On the other hand, sandwich
also defines its own c
and e
'recipes', see :h sandwich-filetype-recipes
. This is what enables the c
insdc
or the e
in sde
. I think these should be enabled by default, if you didn't disable it and it's not working for you, then I suspect that's a sandwich issue, not vimtex.
This can get a bit messy, because for example if I want to add a nested command (let's say change \textit{hello}
to \textit{\textbf{hello}}
I would do saicc
then textbf<CR>
. The first ic
is using vimtex's text object, the second c
is using sandwich's filetype recipes.
BTW, vimtex doesn't switch any mappings, AFAIK. I don't think that sandwich is explicitly supported by vimtex. dsc
and dse
still work for me, I just don't use them. The commands sdc
and sde
also do work for me, but this is because of the sandwich
filetype recipes, not because of vimtex.
In the very next paragraph, the documentation mentions the related
sandwich.vim
. I am asandwich.vim
user. Now, the default mappings of sandwich begins withs
instead of the action. This leads to an inconsistent split usage model for the user, wherein some mappings usesandwich
semantics while others adhere to thesurround.vim
scheme provided by vimtex.It would ease the cognitive burden on the user if
vimtex
can provide a boolean option such aslet g:vimtex_use_sandwich_mapping_scheme
can be provided (which is set to 0 by default to maintain backward compatibility). The ideas is to detect that sandwich is loaded and switch to its mnemonic scheme. i.e.dsc
shall becomesdc
etc.
This might be a good idea. Reasons it might not:
dsc
to sdc
, would it overwrite another action within sandwich.vim? Ref. the last comment by @yongrenjie.It would be very helpful if yuo (or anyone else interested in this) could show me the proper list of mappings required.
BTW, vimtex doesn't switch any mappings, AFAIK.
Correct.
I don't think that sandwich is explicitly supported by vimtex.
Correct. That is, sandwich works well with VimTeX and there is no conflic, so there is some kind of implicit support, I guess?
dsc
anddse
still work for me, I just don't use them. The commandssdc
andsde
also do work for me, but this is because of thesandwich
filetype recipes, not because of vimtex.
Yes, I believe these exist and work quite well. Perhaps also the cse
and csc
variants, although I believe VimTeX may have better completion here. I also believe the csd
may be "better" in VimTeX.
Vimtex's documentation states:
In the very next paragraph, the documentation mentions the related
sandwich.vim
. I am asandwich.vim
user. Now, the default mappings of sandwich begins withs
instead of the action. This leads to an inconsistent split usage model for the user, wherein some mappings usesandwich
semantics while others adhere to thesurround.vim
scheme provided by vimtex.It would ease the cognitive burden on the user if
vimtex
can provide a boolean option such aslet g:vimtex_use_sandwich_mapping_scheme
can be provided (which is set to 0 by default to maintain backward compatibility). The ideas is to detect that sandwich is loaded and switch to its mnemonic scheme. i.e.dsc
shall becomesdc
etc.