Created
August 25, 2013 01:49
-
-
Save supermomonga/6331458 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
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