Tried using the following in my .vimrc
, but somehow it isn't working. Also, is there any down sides to using "Q" also along side the usual q to quit the editor. Apparently, I find stumbling on this issue a lot, but don't see this tweak is most .vimrcs.
noremap Q :quit<CR>
You can press the Esc key. Type SHIFT Z Z to save and exit. Type SHIFT Z Q to exit without saving.
In Vi, write means save, and quit means exit. If you've made mistakes along the way while editing and want to back out (abandon) all non-saved changes, enter Command mode by pressing Esc and typing :q! This command quits without saving any changes and exits Vi.
If you want to quit Vim with :Q
, a simple mapping won't do, because you then won't be able to type Q
in the command-line (which is the mode you would have to map, using :cnoremap
).
You can either just define an uppercase command:
:command! -bar -bang Q quit<bang>
or use the technique described in aliasing a command in vim, which also works for lower-case. Or have a look at cmdalias.vim - Create aliases for Vim commands.
If you want to quit vim with :Q just add this to your vimrc
:command Q q
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With