This project is considered stable

Ask for confirmation before quitting Vim.

I originally wrote this as an answer on vi Stack Exchange: http://vi.stackexchange.com/a/3712/51

The idea is based on the “ConfirmQuit” script: http://www.vim.org/scripts/script.php?script_id=1072

To use it you’ll need to remap keys that “quit” Vim as there’s no other way to prevent Vim from quitting. This plugin comes with the following mappings by default:

cnoremap <silent> q<CR>  :call confirm_quit#confirm(0, 'last')<CR>
cnoremap <silent> wq<CR> :call confirm_quit#confirm(1, 'last')<CR>
cnoremap <silent> x<CR>  :call confirm_quit#confirm(1, 'last')<CR>
nnoremap <silent> ZZ     :call confirm_quit#confirm(1, 'last')<CR>

See :help confirm-quit for the full documentation.

Copyright © 2010-2017 Martin Tournoij <martin@arp242.net>
This document is licensed under a cc-by 4.0 license.