Skip to content

Instantly share code, notes, and snippets.

@holygeek
Created December 11, 2013 12:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save holygeek/7909458 to your computer and use it in GitHub Desktop.
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>
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