Closed alexandreroberts closed 1 year ago
Will work on a fix for this in the next few days; I spent a bit of time working on the same effect for normal-mode surrounds but visual seemed to just slip under my radar.
I will note that I have something like this for your use case: https://github.com/kylechui/config.nvim/blob/main/after/ftplugin/tex.lua#L28
It just enables c
ommand surrounds
Please update to the latest commit and see if the issue is resolved; let me know how it goes!
It works perfectly now. Thanks so much for the fix!
I will note that I have something like this for your use case: https://github.com/kylechui/config.nvim/blob/main/after/ftplugin/tex.lua#L28
It just enables
c
ommand surrounds
Yes, I've been using this feature, it's great. But Sctextquote
takes longer to write than ,tq
. Is there some simple way to harness this c
option to write a more intelligent mapping for ,tq
(i.e., that has the same effect but simply inputs textquote
to the c
option directly rather than prompting the user)?
Change the add
key to be
add = { "\\textquote{", "}" }
See the help menu for more information.
Ah! That makes sense. Sorry for the elementary question; as you can tell, my understanding of the code is very limited, especially in lua. Hopefully I am learning...
No worries, feel free to tag me here (or perhaps in a discussions post) if you have any more questions about the plugin or Lua in general!
Thank you, much appreciated!
Checklist
:h nvim-surround
to see if there might be any relevant information there?Neovim Version
NVIM v0.8.3
Plugin Version
Tagged (Stable)
Minimal Configuration
Sample Buffer
(Where | indicates the boundaries of a visual selection.)
Keystroke Sequence
S]
Expected behavior
is a
in square bracketsActual behavior
Step 1 does indeed happen as expected. But then where the cursor ends up depends on how I made the visual selection. So if I start with the cursor on the
a
and then typevbS]
, then the cursor does indeed end up on the opening bracket. But if I start with the cursor on thei
inis
then typevwS]
, the cursor ends up on neither bracket but rather on thea
(i.e., the place where the cursor was beforenvim-surround
was invoked).I'm not sure this is strictly speaking a bug; perhaps it is even intentional? But to me the most natural behavior would be to consistently end on the opening bracket (or whatever other thing has surrounded the visual selection).
Additional context
I am especially interested in making the behavior consistent because I depended on this behavior while using
vim-surround
(from which I recently moved tonvim-surround
) to write a number of mappings for wrapping visual selection in particular LaTeX commands I use frequently, e.g.,vmap <leader>tq S}i\textquote<ESC>
so that I can time,tq
to wrap a visual selection in\textquote{...}
. Now withnvim-surround
, this produces garbled output.