【已解决】vim 如何让打开文件时光标自动到上次退出该文件时的光标所在位置
发表于 : 2013-12-15 15:08
在我的vimrc加入了
" When editing a file, always jump to the last cursor position
autocmd BufReadPost *
\ if ! exists("g:leave_my_cursor_position_alone") |
\ if line("'\"") > 0 && line ("'\"") <= line("$") |
\ exe "normal g'\"" |
\ endif |
\ endif
为什么每次打开文件光标总是停留在第一行
参考论坛https://www.ubuntu.org.cn/viewtopic.php?f=68&t=289729解决,原因是.viminfo的属性不知道怎么变成了root了。
jindg@kickseed:~$ ls -l /home/jindg/.viminfo
-rw------- 1 root root 3196 12月 15 14:48 /home/jindg/.viminfo
删除它即可。
" When editing a file, always jump to the last cursor position
autocmd BufReadPost *
\ if ! exists("g:leave_my_cursor_position_alone") |
\ if line("'\"") > 0 && line ("'\"") <= line("$") |
\ exe "normal g'\"" |
\ endif |
\ endif
为什么每次打开文件光标总是停留在第一行
参考论坛https://www.ubuntu.org.cn/viewtopic.php?f=68&t=289729解决,原因是.viminfo的属性不知道怎么变成了root了。
jindg@kickseed:~$ ls -l /home/jindg/.viminfo
-rw------- 1 root root 3196 12月 15 14:48 /home/jindg/.viminfo
删除它即可。