Is it possible to have Vim always start at whatever line i was in last time i was working in that given file? And if so, how do i do that?
+4
A:
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.
Marco Mariani
2010-09-13 11:24:27
it's very unreadable, but does just what i need.
Hermann Ingjaldsson
2010-09-13 11:52:19
did you find that somewhere or did you write it yourself?
Hermann Ingjaldsson
2010-09-13 11:53:00
I have a long .vimrc, with stuff sedimented over time. I suggest you have a look at some of the general questions/blog posts about .vimrc and take what you please.
Marco Mariani
2010-09-13 12:08:25
@Hermann Ingjaldsson this code comes from eval.txt vim help file, see `:h last-position-jump`. (except the `g:leave_my_cursor_position_alone` variable).
ZyX
2010-09-13 12:09:05
+1
A:
put this into your .vimrc
set viewoptions=cursor,folds
au BufWinLeave * mkview
au BufWinEnter * silent loadview
Sanek
2010-09-13 16:58:47