Vintage icon indicating copy to clipboard operation
Vintage copied to clipboard

's' after selecting text in visual mode off-by-one issue

Open chronick opened this issue 13 years ago • 6 comments
trafficstars

When selecting text in visual mode, then hitting 's' (to Substitute text), the character after the selection is also deleted.

So if the text is helloc

and I just select hello, then I would expect to be left with c, but instead the whole string is deleted.

Is this a legit bug, or is there a setting controlling this?

chronick avatar Nov 17 '12 21:11 chronick

I posted this problem in the forum long time ago. No one really cares, it seemed.

It would be great if anyone can fix this. Actually, 'c' is quite similar and it works fine. It would work, when there's text selected, let 's' works as the same as 'c'.

princemaple avatar Nov 18 '12 06:11 princemaple

Hmm, now that I know to use 'c', I think I'll be ok. I might be able to map 's' to 'c' via config. If not, then I should be able to. Anyway, thanks for showing me that!

chronick avatar Nov 19 '12 22:11 chronick

I fixed this by changing the motion mapped to the "s" key, in Default.sublime-keymap Try this:

{ "keys": ["s"], "command": "set_action_motion", "args": {
        "action": "enter_insert_mode",
        "action_args": {"insert_command": "vi_delete"},
        "motion": "expand_selection" },
        "context": [{"key": "setting.command_mode"}]
}

alexleach avatar Jan 24 '13 13:01 alexleach

@alexleach beautiful.

princemaple avatar Jan 24 '13 13:01 princemaple

@princemaple Glad you like it :) Just discovered a flaw in it though, in that the character under the cursor doesn't get deleted when not in visual mode. I've added a new commit on the above Pull Request that fixes this. (change vi_delete for vi_right_delete)

alexleach avatar Jan 24 '13 20:01 alexleach

:+1:

Hubro avatar Jun 20 '13 13:06 Hubro