Last Updated: February 25, 2016
·
883
· orangejulius

Alias :W to :w in Vim

If you ever type a bit to fast while saving a file, you might find yourself capitalizing that w. It's not trivial to alias a colon command in vim without side effects (like replacing all W's with w's). Fortunately ZyX on Stackoverflow has a solution

cnoreabbrev <expr> W ((getcmdtype() is# ':' && getcmdline() is# 'W')?('w'):('W'))

2 Responses
Add your response

I'm using this for the same problem: map <C-S> :w<CR>. This enables saving with Ctrl+S.
I'm also using map <C-Q> :qa!<CR>.
I find these two very useful.

over 1 year ago ·

Very nice, but clearly it paves the way for all the evil of emacs to pour into our pure little vim paradise. :P

over 1 year ago ·