Safe redo (Ctrl-Y)

2

2

In ST (Sublime Text for short) the redo action works very strange and inconvenient way, from my point of view.

First test. Type some text, for example

Foo

and then press Ctrl-Y one or several times. You will see:

FooFooFoo

Second test. Again, type something, for example

The cat on the roof.

and then press Backspace to remove the dot at the end of sentence. Okay, and then press Ctrl-Y several times. You will see:

The cat on the ro

It very differs from any text editor/IDE I have used - Brackets, Vim and some more.

Is there some way to fix it?

john c. j.

Posted 2016-04-14T20:20:07.023

Reputation: 250

Answers

4

The default redo/undo keybindings in ST are:

  • ctrl+z: undo
  • ctrl+shift+z: redo
  • ctrl+y: redo_or_repeat (explained in @MattDMo's answer)
  • ctrl+u: soft_undo this does not only undo text changes, but also cursor movements. This can be very useful if you jumped somewhere and want to go back or added a selection you did not want.
  • ctrl+shift+u: soft_redo

Hence the keybinding you want ist ctrl+shift+z.

However if you want to map it to ctrl+y, you can open Preferences >>> Keybindings - User and paste the following:

[
    {
        "keys": ["ctrl+y"],
        "command": "redo"
    }
]

r-stein

Posted 2016-04-14T20:20:07.023

Reputation: 381

1In Mac, use "super+y". – Safwan – 2018-10-28T01:58:00.460

0

CtrlY is not a shortcut for redo, it's a shortcut for "repeat last action". Perform some actions, then click on the Edit menu and see what the menu option for ^Y says. It will most likely say something like "Repeat Insert Characters" if you've just been typing, or "Repeat Left Delete" if you've just been hitting Backspace. It's meant to be used in conjunction with CtrlZ or "Undo last action". For example, you select some text and hit Delete, only to realize you selected too much. You can then hit CtrlZ to undo the delete, and CtrlY to repeat the delete action.

MattDMo

Posted 2016-04-14T20:20:07.023

Reputation: 4 968

@johnc.j. ctrl+shift+z is the hotkey for redo – r-stein – 2016-04-18T13:08:00.853