Search code examples
emacsundo-redo

How do I redo multiple times in emacs with a shortcut like ctrl+_


I like how I can undo multiple times with ctrl+_, but I can't seem to figure out how to redo that supports multiple times with a similar quick shortcut.

Also, I can't seem to figure out how to skip multiple lines up and down at once.


Solution

  • I can't seem to figure out how to redo that supports multiple times with a similar quick shortcut.

    Sorry if you know this...

    You can switch undo to redo by hitting C-g once. So it is not one shortcut key. The behavior is not like as ordinary editor. But I think it is very quick way of redo. See the behavior below.

    Emacs undo state changes:

    ----example1------
    time |typed |text
    -----+------+-----
    1    |      |''
    2    |'a'   |'a'
    3    |'b'   |'ab'
    4    |'c'   |'abc'
    5    |'d'   |'abcd'
    6    |udno  |'abc'
    7    |undo  |'ab'
    8    |undo  |'a'
    9    |undo  |''
    10   |C-g   |''     <---switch
    11   |undo  |'a'    <---redo!
    12   |undo  |'ab'   <---redo!
    13   |undo  |'abc'  <---redo!
    14   |undo  |'abcd' <---redo!
    
    ----example2------
    time |typed |text
    -----+------+-----
    1    |      |''
    2    |'a'   |'a'
    3    |'b'   |'ab'
    4    |'c'   |'abc'
    5    |'d'   |'abcd'
    6    |udno  |'abc'
    7    |undo  |'ab'
    8    |undo  |'a'
    9    |undo  |''
    10   |C-g   |''    <---switch
    11   |undo  |'a'   <---redo!
    12   |undo  |'ab'  <---redo!
    13   |'x'   |'abx' <---switch
    14   |undo  |'ab'
    15   |undo  |'a'
    16   |C-g   |'a'   <---switch
    17   |undo  |'ab'  <---redo!!
    18   |undo  |'abx' <---redo!!