:x Instead of :wq in Vim
I’m not sure why, but in college everyone seemed to only use :wq
to save and quit in Vim. Perhaps it is because we were taught :w
(save) and :q
(quit) separately, so :wq
became the default combo.
Well, there’s a lesser-known easier way to save and quit in Vim: :x
! There you go. I saved you one less keystroke.
There are minor differences betweeen these two commands. :wq
forces a write to the disk even if there are no changes, but :x
doesn’t. Practically speaking, there is no difference. So just use :x
instead!