Created
December 11, 2013 12:21
-
-
Save holygeek/7909458 to your computer and use it in GitHub Desktop.
Hitting Q once quits vim via :q<cr>
Hitting Q twice in a row quits vim via :q!<cr>
This file contains 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
if has("reltime") | |
let g:lastQuitAttempt = reltime() | |
endif | |
function! Quit() | |
if has("reltime") | |
let diff = reltime(g:lastQuitAttempt, reltime()) | |
let g:lastQuitAttempt = reltime() | |
let seconds = diff[0] | |
let ms = diff[1] | |
" How fast can you hit Q twice? | |
if seconds == 0 && ms < 200000 | |
return ":q!\<cr>" | |
endif | |
endif | |
return ":q\<cr>" | |
endfun | |
nnoremap <expr> Q Quit() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment