sublimehq / Vintage

Vintage mode adds a vi style command mode to Sublime Text 2
http://www.sublimetext.com/docs/2/vintage.html
579 stars 76 forks source link

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

Open chronick opened 11 years ago

chronick commented 11 years ago

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?

princemaple commented 11 years ago

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'.

chronick commented 11 years ago

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!

alexleach commented 11 years ago

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"}]
}
princemaple commented 11 years ago

@alexleach beautiful.

alexleach commented 11 years ago

@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)

Hubro commented 11 years ago

:+1: