I use the Vim plugin ack.vim, but I don't understand why the command is :Ack
with a capital "A" (a little annoying to hold shift).
Is it possible to remap this to :ack
?
Built-in commands start with a lowercase character and custom commands start with an uppercase character. Those are the rules. Vim simply won't let you define a custom command starting with a lowercase.
If you don't like it, nothing prevents you from creating a normal mode mapping:
nnoremap <leader>a :Ack<Space>
which is even faster than :ack<Space>
.
Yes, but It is not as simple as it sounds:
cnoreabbrev <expr> ack getcmdtype() == ':' && getcmdline() ==# 'ack' ? 'Ack' : 'ack'
Long story short vim does not provide a native way to create lowercase commands. Using mappings causes delays so abbreviations are preferred. The trick is to be careful when the abbreviation should expand as cabbrev
's expand at other times than just ex commands and in other places e.g. search. Here is another thread talking about this point.
Hari Krishna Dara created a plugin: cmdalias.vim. It uses a variation of the technique above
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With