vim-surround
vim-surround copied to clipboard
Bug: Adding to a surround has weird spacing
I was trying to add to a surround and got this:
text = {key: 'a', other: 'b'}
^ cursor here
And running ysa'[ produces:
text = {key:[ 'a' ], other: 'b'}
^ cursor here
And running ysa'] produces:
text = {key:[ 'a'], other: 'b'}
^ cursor here
I can kinda see where it's coming from cause a traditionally includes spaces, but in this case the text object is ' not a word so I think it should behave more normally like:
text = {key: [ 'a' ], other: 'b'}
^ cursor here
text = {key: ['a'], other: 'b'}
^ cursor here
even better if the cursor stays where it is like:
text = {key: [ 'a' ], other: 'b'}
^ cursor here
text = {key: ['a'], other: 'b'}
^ cursor here
I noticed this as well. Seems to only happen when using the a modifier...
You can use 2i
modifier instead of a
to select a whole word without spaces. Look :h i'.
In your case, ys2i']
does what you want.
I didn't know this until today 😄
It might be useful if vim-surround converts a"
, a'
and a`
to 2i"
, 2i'
and 2i`
.
At first glance that sounds reasonable.
Odd that this behavior only appears when selecting around quote-like objects ('
, "
, `), and not parentheses, brackets, etc. I wonder why that is?
Cool! Thanks so much, I added this to my .vimrc
in the mean time:
nmap ysa' ys2i'
nmap ysa" ys2i"
nmap ysa` ys2i`