Created
May 4, 2018 08:08
-
-
Save adscriven/2a1b3091dc021e566141941ead56126c to your computer and use it in GitHub Desktop.
This file contains hidden or 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
" From: | |
" https://github.com/igemnace/vim-config/blob/master/cfg/plugin/quick-buffer.vim | |
" original problem: :B command that extends :b such that I don't have to hit * | |
function! QuickBuffer(pattern) abort | |
redraw | |
let p = substitute(a:pattern, '\s\+$', '', '') | |
if empty(p) | |
call feedkeys(":B \<C-d>") | |
return | |
endif | |
let l:globbed = join(split(p, '\s\+'), '*') | |
try | |
execute 'buffer ' . l:globbed | |
catch | |
call feedkeys(':B ' . l:globbed . "\<C-d>\<C-u>B " . p, 'n') | |
endtry | |
endfunction | |
command! -nargs=* -complete=buffer B call QuickBuffer(<q-args>) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment