Optionally restore cursor position
This uses the '" mark to restore the last cursor position when opening a file, implemented as BufReadPost autocmd.
This commit is contained in:
parent
a576a6370a
commit
7107538da0
2 changed files with 26 additions and 5 deletions
|
@ -9,10 +9,11 @@ endif
|
|||
let g:autoloaded_startify = 1
|
||||
|
||||
" Init: values {{{1
|
||||
let s:cmd = (get(g:, 'startify_change_to_dir', 1) ? ' <bar> lcd %:h' : '') . '<cr>'
|
||||
let s:numfiles = get(g:, 'startify_files_number', 10)
|
||||
let s:show_special = get(g:, 'startify_enable_special', 1)
|
||||
let s:session_dir = resolve(expand(get(g:, 'startify_session_dir',
|
||||
let s:cmd = (get(g:, 'startify_change_to_dir', 1) ? ' <bar> lcd %:h' : '') . '<cr>'
|
||||
let s:numfiles = get(g:, 'startify_files_number', 10)
|
||||
let s:show_special = get(g:, 'startify_enable_special', 1)
|
||||
let s:restore_position = get(g:, 'startify_restore_position')
|
||||
let s:session_dir = resolve(expand(get(g:, 'startify_session_dir',
|
||||
\ has('win32') ? '$HOME\vimfiles\session' : '~/.vim/session')))
|
||||
|
||||
" Function: #insane_in_the_membrane {{{1
|
||||
|
@ -71,6 +72,9 @@ function! startify#insane_in_the_membrane() abort
|
|||
endif
|
||||
|
||||
autocmd startify CursorMoved <buffer> call s:set_cursor()
|
||||
if s:restore_position
|
||||
autocmd startify BufReadPost * call s:restore_position()
|
||||
endif
|
||||
|
||||
1
|
||||
call cursor((s:show_special ? 4 : 2) + s:offset_header, 5)
|
||||
|
@ -412,4 +416,12 @@ function! s:get_index_as_string(idx) abort
|
|||
endif
|
||||
endfunction
|
||||
|
||||
" Function: s:restore_position {{{1
|
||||
function! s:restore_position() abort
|
||||
autocmd! startify *
|
||||
if line("'\"") > 0 && line("'\"") <= line('$')
|
||||
call cursor(getpos("'\"")[1:])
|
||||
endif
|
||||
endfunction
|
||||
|
||||
" vim: et sw=2 sts=2
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue