In nano, I like that I can just hit ctrl x to exit a file I'm editing without saving it. I also like that I can type ctrl o to save a file.

I've completed the vim trainer and am trying to like vim. Still, I continue for find "the steps for exiting and saving" laborious compared to nano.

Does everyone else just tolerate this? Are there alternatives in vim for these tasks that I'm unaware of?

1 Answer 1


:help ZZ

ZZ          Write current file, if modified, and close the current
            window (same as ":x").
            If there are several windows for the current file,
            only the current window is closed.

ZQ          Quit without checking for changes (same as ":q!").

And you can always mimic what nano has by adding following to your vimrc:

noremap <C-x> <cmd>q!<CR>
noremap <C-o> <cmd>wq<CR>
inoremap <C-x> <cmd>q!<CR>
inoremap <C-o> <cmd>wq<CR>

Note though, both <C-o> and <C-x> has built-in functionality...

PS, if your vim is old and doesn't have <cmd> modifier, you can map it like this:

nnoremap <C-x> :q!<CR>
nnoremap <C-o> :wq<CR>
xnoremap <C-x> :<C-u>q!<CR>
xnoremap <C-o> :<C-u>wq<CR>
inoremap <C-x> <ESC>:q!<CR>
inoremap <C-o> <ESC>:wq<CR>

PPS, there is also built-in <C-w>q to close current window and if it is the last one, vim (if a buffer in that window is saved).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.