Vim start with cursor where last went off [closed]

坚强是说给别人听的谎言 提交于 2020-01-14 12:59:44

问题


How do i make Vim always start at the line I was at when i exited that given file last time?


回答1:


Put this in your .vimrc:

" When editing a file, always jump to the last cursor position
 au BufReadPost *
       \ if ! exists("g:leave_my_cursor_position_alone") |
       \     if line("'\"") > 0 && line ("'\"") <= line("$") |
       \         exe "normal g'\"" |
       \     endif |
       \ endif

then you can use :let g:leave_my_cursor_position_alone=1 at runtime to deactivate the feature.




回答2:


put this into your .vimrc

set viewoptions=cursor,folds

au BufWinLeave * mkview

au BufWinEnter * silent loadview


来源:https://stackoverflow.com/questions/3699904/vim-start-with-cursor-where-last-went-off

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!