Guo Qiang

vim 记住上次编辑和浏览的位置

发布日期 2023-06-06 09:27:58已读 1127 次FAQ
image

在 Debian 系统中使用 vim 编辑文件后再次打开又回到第一行,这样非常不方便,编辑 /etc/vim/vimrc 中,加入以下语句,就可以在打开文件后回到关闭文件前编辑和浏览的位置了


" Uncomment the following to have Vim jump to the last position when
" reopening a file
if has("autocmd")
  au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif
endif


Copyright © 2019~2024 Guo Qiang
Pages viewed 16,753,261