Skip to content

Instantly share code, notes, and snippets.

@supermomonga
Created August 25, 2013 01:49
Show Gist options
  • Save supermomonga/6331458 to your computer and use it in GitHub Desktop.
Save supermomonga/6331458 to your computer and use it in GitHub Desktop.
function! SelectInteractive(question, candidates) " {{{
try
let a:candidates[0] = toupper(a:candidates[0])
let l:select = 0
while index(a:candidates, l:select, 0, 1) == -1
let l:select = input(a:question . ' [' . join(a:candidates, '/') . '] ')
if l:select == ''
let l:select = a:candidates[0]
endif
endwhile
return tolower(l:select)
finally
redraw!
endtry
endfunction " }}}
function! BufferWipeoutInteractive() " {{{
if &modified == 1
if SelectInteractive('Buffer is unsaved. Force quit?', ['n', 'y']) == 'y'
bwipeout!
endif
else
bwipeout
endif
endfunction " }}}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment