Closed tam5 closed 5 years ago
Last time I used vim, cs was used to change surroundings, while ys was used to add them (mnemonic for you surround). Are you sure you haven't changed the default vim bindings?
strangely enough, yes, in stock vim with vim-surround csw'
does what you say, which I find rather odd. ysw'
is what you really would mean. you could drop the i
.
I just found out - this is actually documented behaviour:
The letters w, W, and s correspond to a |word|, a |WORD|, and a |sentence|,
respectively. These are special in that they have nothing to delete, and
used with |ds| they are a no-op. With |cs|, one could consider them a
slight shortcut for ysi (cswb == ysiwb, more or less).
https://github.com/tpope/vim-surround/blob/master/doc/surround.txt
yeah, seems like we have to fix it. thanks for reporting @tam5. PRs welcome by the way.
good catch @edkolev
I must say though, it makes the "api" a bit bizarre. cs (change surrounding) obviously takes a surrounding, and a word isn't a surrounding. Very confusing if you ask me.
I could argue that it makes some sense since you are changing what's surrounding the word with something else. Honestly though, its just what my fingers do now... and I'd rather press 4, somewhat close together keys, than 5 all over the place keys.
Took a quick look, but given this is indeed sort of a shortcut that breaks the mold, it wasn't immediately clear how it should be implemented. Any suggestions?
yes, I think the fix lies within this snippet. It is a possibility that you might have to fix the evil-surround-valid-char-p key
function because I suspect that w
would not qualify as a valid char as per the function. As always, be sure to implement tests if you follow through with the PR.
In vim, i used to do
csw'
all the time, which in the following example hovering inside 'Hello' would changeto
with
evil-surround
it seems instead i have to doysiw'
.Maybe I am crazy and should just relearn the new binding, but is there any way to get
csw
to work exactly like vim did?