Add cursor position history
This commit is contained in:
parent
9d45f6a18c
commit
5fb25b5f16
1 changed files with 42 additions and 0 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue