From 85909e3f0c2b93f2853c6de13669f25d5679d630 Mon Sep 17 00:00:00 2001 From: perfectworks Date: Wed, 4 Sep 2013 18:40:33 +0800 Subject: [PATCH] auto restore cursor to last edit position when open file --- .vimrc | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/.vimrc b/.vimrc index d747c911f..2b3a1e24d 100644 --- a/.vimrc +++ b/.vimrc @@ -118,6 +118,24 @@ " set it to the first line when editing a git commit message au FileType gitcommit au! BufEnter COMMIT_EDITMSG call setpos('.', [0, 1, 1, 0]) + " http://vim.wikia.com/wiki/Restore_cursor_to_file_position_in_previous_editing_session + " Restore cursor to file position in previous editing session + " To disable this, add the following to your .vimrc.before.local file: + " let g:spf13_no_restore_cursor = 1 + if !exists('g:spf13_no_restore_cursor') + function! ResCur() + if line("'\"") <= line("$") + normal! g`" + return 1 + endif + endfunction + + augroup resCur + autocmd! + autocmd BufWinEnter * call ResCur() + augroup END + endif + " Setting up the directories { set backup " Backups are nice ... if has('persistent_undo')