Closed YeungOnion closed 2 years ago
Your solution is very close. The problem is that after the command c/+>/e
, you're in insert mode, not normal mode. You could escape insert mode, restore the search value, and then re-enter insert mode. However, this is difficult to do without moving your cursor. I recommend using <C-o>
, which allows you to execute one normal command while staying in insert mode. Thus "\<ESC>:let search = @/ | call search('<+.*+>')\<CR>\"_c/+>/e\<CR>\<C-o>:let @/ = search\<CR>"
should work.
I admit, though, that this is not ideal. I think it is better to make a new function called quicktexJump()
, so you that you can simply do ":call quicktexJump()\<CR>"
instead. I will make this new function soon and add it to the plugin.
Thanks for the tip! But I'm a little confused because I imagine I would've seen :let ...
put to the buffer, but I didn't see that. I looked at :h abbreviations
, but admittedly, I've only minimally looked at how quicktex actually implements the abbreviation effect.
I also tried with :keeppatterns
for the search and the normal mode command to change but I couldn't get that to work either. Maybe that's an option for quicktexJump?
When I tried your suggestion, I did see :let ...
put into the buffer. I'm not sure why it didn't show up for you.
QuickTex is pretty simple. It just remaps <SPC>
to check whether the previous word is in the dictionary. If there's no match, then it inserts a space. If there is a match, then it looks up the corresponding string in the dictionary and executes it as keypresses.
Thank you for the suggestion to use :keeppatterns
. I switched from Vim to Emacs a few years ago, so I've forgotten how to program in Vim script.
I've added a new function called QuicktexJump()
and pushed the commit. If you find any problems with it, please let me know!
Looks good on my end. I figured out why I don't match behavior. I added my personal expansions in after/ftplugin/*.vim and I source them with :source $HOME/.vim/after/ftplugin
, but if I check the value with :let
it doesn't appear I've changed it. Similarly, I call :let g:quicktex_...='...'
and it also doesn't change the value of the dictionary, so that's the issue. I never learned much about vim dictionaries, but I'm thinking of leaving vim, so I won't dig into this.
Lastly, thanks for maintaining this despite using emacs. VimScript is rough.
I know the suggested dict value for
quicktex_tex[' ']
is"\<ESC>:call search('<+.*+>')\<CR>\"_c/+>/e\<CR>"
, but is there a way I can set it to not clobber the register? I tried"\<ESC>:let search = @/ | call search('<+.*+>')\<CR>\"_c/+>/e\<CR>:let @/ = search\<CR>"
instead, but that's not working for me. I'm taking the tip to save old search from this SO question, thought there might be a name collision forsearch
, but appears not.