diff options
author | Jesse Luehrs <jesse.luehrs@stripe.com> | 2015-02-25 11:27:39 -0800 |
---|---|---|
committer | Jesse Luehrs <doy@tozt.net> | 2015-02-25 11:34:28 -0800 |
commit | 0263fcc1a02ae5d5d9569178963b904cbf045e05 (patch) | |
tree | a0131b851a1f801fe5ec6d1b678141bff5c57374 /vimrc | |
parent | 3b7f1a1982f7252d1e6fb73b5c67be83439980b6 (diff) | |
download | conf-0263fcc1a02ae5d5d9569178963b904cbf045e05.tar.gz conf-0263fcc1a02ae5d5d9569178963b904cbf045e05.zip |
make sure the up arrow always goes to the last open file
Diffstat (limited to 'vimrc')
-rw-r--r-- | vimrc | 12 |
1 files changed, 12 insertions, 0 deletions
@@ -328,6 +328,7 @@ if $SHELL =~ 'zsh' && exists('g:_zsh_hist_fname') autocmd VimEnter * call <SID>init_zsh_hist() autocmd BufNewFile,BufRead * call <SID>zsh_hist_append() autocmd BufDelete * call <SID>remove_initial_file(expand("<afile>")) + autocmd VimLeave * call <SID>reorder_zsh_hist() function! s:remove_initial_file (file) if has_key(s:initial_files, a:file) @@ -371,6 +372,17 @@ if $SHELL =~ 'zsh' && exists('g:_zsh_hist_fname') endif endif endfunction + function! s:reorder_zsh_hist () + let current_file = expand("%:~:.") + if filereadable(g:_zsh_hist_fname) + let hist = readfile(g:_zsh_hist_fname) + if !has_key(s:initial_files, current_file) + call filter(hist, 'v:val != current_file') + endif + call add(hist, current_file) + call writefile(hist, g:_zsh_hist_fname) + endif + endfunction endif " }}} " start with the current fold open {{{ |