Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Remapping :Wq to :wq in vim

A lot of times, when I want to save a file in vim and immediately exit thereafter, I accidentally type :Wq instead of :wq.

Vim naturally gives me this error:

E492: Not an editor command: Wq 

I'm wondering, is it possible to remap :Wq to :wq?

like image 540
franzlorenzon Avatar asked Oct 10 '12 10:10

franzlorenzon


2 Answers

You can create a simple vim command that is basically an alias for wq. Place the following in your ~/.vimrc file:

command! Wq wq

For more help see:

:h :command
like image 162
Peter Rincker Avatar answered Oct 17 '22 09:10

Peter Rincker


You can also use ZZ which is the same as :wq<CR>

like image 21
applicative_functor Avatar answered Oct 17 '22 09:10

applicative_functor