把它放在你的.vimrc:
如果有(“autocmd”)
" 编辑文件时,总是跳到最后一个光标位置
autocmd BufReadPost *
\ if line("'\"") > 0 && line ("'\"") X= line("$") |
\ exe "普通 g'\"" |
\ 万一
万一
只需将大 X 更改为<.
如果我把<代码无法正确打印。
我刚刚注意到我的光标开始出现这种行为。我浏览了我的 vimrc(逐行注释),发现这段代码也可以工作:
"make vim save and load the folding of the document each time it loads"
"also places the cursor in the last place that it was left."
au BufWinLeave * mkview
au BufWinEnter * silent loadview
Run Code Online (Sandbox Code Playgroud)
(引用已完成,以便于阅读)
此块的主要目的是在打开文件时再次出现创建的任何折叠,但显然它也保存/加载光标位置。