vim - 如何重复 Vim 中的最后 n 个更改?

标签 vim repeat

执行 . 会重复上次更改。执行 2. 会重复上次更改两次。

但是想象一下我想在最后一个更改之前重复更改。我如何在 Vim 中执行此操作?

最佳答案

不认为可以,请参阅 :help 。 但是,您可以做的是为您的编辑录制宏,您有很多寄存器可供选择{0 -9a-zA-Z"}(大写以追加)。 然后使用例如@u 表示编辑 1,@t 表示编辑 2,依此类推。

来自Best of VIM Tips的关于录音的重要提示

" Recording (BEST TIP of ALL)
qq  # record to q
your complex series of commands
q   # end recording
@q to execute
@@ to Repeat
5@@ to Repeat 5 times
qQ@qq                             : Make an existing recording q recursive *N*
" editing a register/recording
"qp                               :display contents of register q (normal mode)
<ctrl-R>q                         :display contents of register q (insert mode)
" you can now see recording contents, edit as required
"qdd                              :put changed contacts back into q
@q                                :execute recording/register q

查看这些以获取更多重复提示:

:&     last substitute
:%&    last substitute every line
:%&gic last substitute every line confirm
g%     normal mode repeat last substitute
g&     last substitute on all lines
@@     last recording
@:     last command-mode command
:!!    last :! command
:~     last substitute
:help repeating

关于vim - 如何重复 Vim 中的最后 n 个更改?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6644141/

相关文章:

regex - 我可以让 vim 接受\b 而不仅仅是\< 和\> 吗?

vim - 如何重命名由 setloclist 内置函数提供支持的 'Quickfix' 标题?

replace - 用 Vim 文件中其他地方的寄存器或行范围的内容替换

swift - 更改 UNTimeIntervalNotificationTrigger 的重复值

vim - 'gq' 命令将注释行与非注释行合并

vim - Screen + vim 导致 Shift-Enter 插入 'M' 和换行符

javascript - 创建重复表单部分,删除字段值

c - 为什么它重复源字符串的最后四个字符

android - 我可以在循环中使用ArrayList <String>,map或hashmap作为表达式或语句来减少代码重复吗?

c - 查找数组中出现两次的数字