1
0
Fork 0
mirror of synced 2024-11-22 08:45:34 -05:00

Add cursor position history

This commit is contained in:
Mario Minners 2012-08-26 10:46:04 +02:00
parent 9d45f6a18c
commit 5fb25b5f16

View file

@ -406,3 +406,45 @@ function! <SID>BufcloseCloseIt()
execute("bdelete! ".l:currentBufNum)
endif
endfunction
""""""""""""""""""""""""""""""
" => Position history
""""""""""""""""""""""""""""""
"Remeber something on close
set viminfo='10,\"100,:20,%,n~/.vim_runtime/tmp_dirs/viminfo
"Restore last position of the Document
function! ResCur()
if line("'\"") <= line("$")
normal! g`"
return 1
endif
endfunction
if has("folding")
function! UnfoldCur()
if !&foldenable
return
endif
let cl = line(".")
if cl <= 1
return
endif
let cf = foldlevel(cl)
let uf = foldlevel(cl - 1)
let min = (cf > uf ? uf : cf)
if min
execute "normal!" min . "zo"
return 1
endif
endfunction
endif
augroup resCur
autocmd!
if has("folding")
autocmd BufWinEnter * if ResCur() | call UnfoldCur() | endif
else
autocmd BufWinEnter * call ResCur()
endif
augroup END