Merge branch 'restore-cursor-position'

This commit is contained in:
Marco Hinz 2013-08-04 18:55:37 +02:00
commit 22edae78d1
2 changed files with 26 additions and 5 deletions

View file

@ -9,10 +9,11 @@ endif
let g:autoloaded_startify = 1 let g:autoloaded_startify = 1
" Init: values {{{1 " Init: values {{{1
let s:cmd = (get(g:, 'startify_change_to_dir', 1) ? ' <bar> lcd %:h' : '') . '<cr>' 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:numfiles = get(g:, 'startify_files_number', 10)
let s:show_special = get(g:, 'startify_enable_special', 1) let s:show_special = get(g:, 'startify_enable_special', 1)
let s:session_dir = resolve(expand(get(g:, 'startify_session_dir', 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'))) \ has('win32') ? '$HOME\vimfiles\session' : '~/.vim/session')))
" Function: #insane_in_the_membrane {{{1 " Function: #insane_in_the_membrane {{{1
@ -70,6 +71,9 @@ function! startify#insane_in_the_membrane() abort
endif endif
autocmd startify CursorMoved <buffer> call s:set_cursor() autocmd startify CursorMoved <buffer> call s:set_cursor()
if s:restore_position
autocmd startify BufReadPost * call s:restore_position()
endif
1 1
call cursor((s:show_special ? 4 : 2) + s:offset_header, 5) call cursor((s:show_special ? 4 : 2) + s:offset_header, 5)
@ -411,4 +415,12 @@ function! s:get_index_as_string(idx) abort
endif endif
endfunction 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 " vim: et sw=2 sts=2

View file

@ -182,6 +182,14 @@ Default: does not exist
Show <empty buffer> and <quit>. Show <empty buffer> and <quit>.
============-
let g:startify_restore_position = 0
Jump to the last cursor position when opening a file. You don't need this, if
you already have this in your vimrc: |last-position-jump|.
============- ============-
let g:startify_custom_indices = [] let g:startify_custom_indices = []
@ -319,7 +327,8 @@ getting feedback! Same for issues or feature requests.
Thank you for flying mhi airlines. Get the Vim on! Thank you for flying mhi airlines. Get the Vim on!
You can also follow me on Twitter: [@_mhinz_](https://twitter.com/_mhinz_) You can also follow me on Twitter: @_mhinz_
============================================================================== ==============================================================================
8. License *startify-license* 8. License *startify-license*