键入:make后恢复光标位置

时间:2020-09-30 12:34:05

标签: vim

我在.vimrc中使用以下命令来重新打开文件后恢复光标位置:

" Copied from defaults.vim
" Put these in an autocmd group, so that you can revert them with:
" ":augroup vimStartup | au! | augroup END"
augroup vimStartup
  au!

  " When editing a file, always jump to the last known cursor position.
  " Don't do it when the position is invalid, when inside an event handler
  " (happens when dropping a file on gvim) and for a commit message (it's
  " likely a different one than last time).
  autocmd BufReadPost *
    \ if line("'\"") >= 1 && line("'\"") <= line("$") && &ft !~# 'commit'
    \ |   exe "normal! g`\""
    \ | endif

augroup END

问题是当我键入:make时,光标位置没有恢复;光标仅出现在键入:make之前的行首。

您对如何解决此问题有任何建议吗?谢谢您的帮助。

1 个答案:

答案 0 :(得分:0)

命令:make似乎没有抛出BufReadPost,因此自动命令将不会执行。

您可以执行:make | norm! ``

:help ''

相关问题