Created
January 23, 2016 22:22
-
-
Save claytron/6d3fd25104729f04cbc8 to your computer and use it in GitHub Desktop.
Most Recently Used Buffer search using FZF in Vim
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" Use 'ffr' in normal mode to start it | |
nmap ffr :MRUFilesCWD<CR> | |
" MRU handling, limited to current directory | |
command! MRUFilesCWD call fzf#run({ | |
\ 'source': s:mru_files_for_cwd(), | |
\ 'sink': 'edit', | |
\ 'options': '-m -x +s --prompt=MRU:'.shellescape(pathshorten(getcwd())).'/', | |
\ 'down': '40%' }) | |
" This relies on the yegappan/mru plugin for live MRU updating. Also relies on | |
" the fact that you don't change the location of the file it uses as its cache. | |
function! s:mru_files_for_cwd() | |
return map(filter( | |
\ systemlist("sed -n '2,$p' ~/.vim_mru_files"), | |
\ "v:val =~ '^" . getcwd() . "' && v:val !~ '__Tagbar__\\|\\[YankRing]\\|fugitive:\\|NERD_tree\\|^/tmp/\\|.git/'" | |
\ ), 'fnamemodify(v:val, ":p:.")') | |
endfunction |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment