很容易转到当前缓冲区中的最后一个编辑位置。
看如何返回到 Vim 中最后一行之前编辑的行?更改列表是缓冲区本地的,每个缓冲区都有自己的更改列表。
然而,我从最近编辑的缓冲区导航到另一个缓冲区是很常见的,并且以某种方式返回到原始缓冲区中的最后一个编辑位置会很好。有没有办法返回到上次插入或修改发生的地方?
您可以将以下内容放入 vimrc 中
autocmd InsertLeave * execute 'normal! mI'
and press `-I to jump back to the position where you left your Insert mode. Since I
is an uppercase, it works across buffers.
附录(评论后)
阅读@Garbor Marton 的评论后,
我自己写了一个函数
let g:detect_mod_reg_state = -1
function! DetectRegChangeAndUpdateMark()
let current_small_register = getreg('"-')
let current_mod_register = getreg('""')
if g:detect_mod_reg_state != current_small_register ||
\ g:detect_mod_reg_state != current_mod_register
normal! mM
let g:detect_mod_reg_state = current_small_register
endif
endfunction
" Mark I at the position where the last Insert mode occured across the buffer
autocmd InsertLeave * execute 'normal! mI'
" Mark M at the position when any modification happened in the Normal or Insert mode
autocmd CursorMoved * call DetectRegChangeAndUpdateMark()
autocmd InsertLeave * execute 'normal! mM'
我喜欢使用原版I
专门为插入模式更改注册,所以这里我使用M
注册任何修改,包括r,x,d,y
和最后的插入模式。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)