Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- " Automatically open buffer when shortest partial tab expands to unique name
- " Barry Arthur, Mar 10 2012
- function! Buffalo(...)
- "echom 1
- let cmdline = getcmdline()
- if cmdline !~ '\C^b\%[uffer]'
- "echom 2
- return ' '
- endif
- if !a:0
- call g:bl.update()
- call feedkeys("\<C-G>")
- "echom 3
- return ' '
- endif
- let char = getchar()
- if char !~ '\d\+'
- call feedkeys(char)
- "echom 4
- return ''
- endif
- let char = nr2char(char)
- let partial = matchstr(cmdline, '^\a\+ \zs.*').char
- let bl = g:bl.filter('v:val["name"] =~ "' . partial . '"')
- if len(bl.buffers) == 1
- "echom 5
- return char."\<CR>"
- else
- "echom 6
- call feedkeys(char."\<C-D>\<C-G>")
- return ""
- endif
- endfunction
- cnore <expr> <C-G> Buffalo(1)
- cnoremap <expr> <Space> Buffalo()
Advertisement
Add Comment
Please, Sign In to add comment