Define commands starting with lowercase letter

5 Points

Lifepillar Lifepillar

8 years ago

As you know, user-defined commands must start with an uppercase letter. Sometimes, one would want a command starting with a lowercase letter, just as predefined commands. You may use :cnoreabbrev for that. See an example below.

Use sparingly (Vim's rule is there for a reason)!

" Save file with sudo
command! -nargs=0  :WriteWithSudo :w !sudo tee % >/dev/null

" Use :ww instead of :WriteWithSudo
cnoreabbrev ww WriteWithSudo