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

Open
chronick opened this Issue Nov 17, 2012 · 6 comments

Comments

Projects
None yet
4 participants
@chronick

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

This comment has been minimized.

Show comment Hide comment
@princemaple

princemaple Nov 18, 2012

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

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

This comment has been minimized.

Show comment Hide comment
@chronick

chronick Nov 19, 2012

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!

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

This comment has been minimized.

Show comment Hide comment
@alexleach

alexleach Jan 24, 2013

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"}]
}

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

This comment has been minimized.

Show comment Hide comment
@princemaple

princemaple Jan 24, 2013

@alexleach beautiful.

@alexleach beautiful.

@alexleach

This comment has been minimized.

Show comment Hide comment
@alexleach

alexleach Jan 24, 2013

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

@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 pushed a commit to alexleach/Vintage that referenced this issue May 15, 2013

Alex Leach
Rebase 3 separate commits into one. Fixes #151, fixes #164 and fixes #…
…173. Relates to the s command-mode key, being off by one.
@Hubro

This comment has been minimized.

Show comment Hide comment
@Hubro

Hubro Jun 20, 2013

👍

Hubro commented Jun 20, 2013

👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment