what can the dot command repeat, exactly?

后端 未结 4 955
慢半拍i
慢半拍i 2020-12-29 05:13

Vimmers know that . can repeat simple changes. I tried to build a list of what can be repeated or not, but is there a list?

I tried to list what I know

相关标签:
4条回答
  • 2020-12-29 05:48

    I believe a change is any command that modifies the current buffer. The . command excludes Ex commands (because that's a different mode that was bolted onto vi in the far history, I guess), and can optionally include yanks.

    So for your list, :help change.txt, filtered for Ex commands, is probably the best source.

    Note that when a change command cannot be applied (i.e. it beeps), it is also not registered for repeat; the command execution must be successful.

    0 讨论(0)
  • 2020-12-29 05:50

    some combination with v/V can be "dot" repeated too.

    e.g.

    Vgq, v/VU or v/Vu

    0 讨论(0)
  • 2020-12-29 05:53

    Tim Pope's repeat.vim can make repeat many more things (including stuff like surround.vim and other must haves).

    To repeat a motion, look at , / ; (forward/reverse direction).

    To repeat an Ex command, @: is a good key combination

    0 讨论(0)
  • 2020-12-29 06:01

    Insert mode expression register is NOT re-evaluated

    Example: If you want to sort following inline lists of numbers,

     first 3,2,17,198,232,1,999 and some other text
     second 1,2,3,71,98,4,5 and some more text
    

    consider these two ways using the expression register:

    1. ciW and then <C-r>=join(sort([<C-r>"]), ',')<CR>
    2. ciW and then <C-r>=join(sort(split(expand(@"), ',')), ',')<CR>

    If you try to repeat either of them for the second line with ., vim simply enters again the same list from the first line. This might be expected by others but I was hoping that for the second way the expression register would be re-evaluated.

    0 讨论(0)
提交回复
热议问题