Skip to content

Instantly share code, notes, and snippets.

@adscriven
Created May 4, 2018 08:08
Show Gist options
  • Save adscriven/2a1b3091dc021e566141941ead56126c to your computer and use it in GitHub Desktop.
Save adscriven/2a1b3091dc021e566141941ead56126c to your computer and use it in GitHub Desktop.
" 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