summaryrefslogtreecommitdiffstats
path: root/vimrc
diff options
context:
space:
mode:
authorJesse Luehrs <jesse.luehrs@stripe.com>2015-02-25 11:27:39 -0800
committerJesse Luehrs <doy@tozt.net>2015-02-25 11:34:28 -0800
commit0263fcc1a02ae5d5d9569178963b904cbf045e05 (patch)
treea0131b851a1f801fe5ec6d1b678141bff5c57374 /vimrc
parent3b7f1a1982f7252d1e6fb73b5c67be83439980b6 (diff)
downloadconf-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--vimrc12
1 files changed, 12 insertions, 0 deletions
diff --git a/vimrc b/vimrc
index 5702a1d..0232a3f 100644
--- a/vimrc
+++ b/vimrc
@@ -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 {{{