yaohunzhanyue / collcetion

6 stars 0 forks source link

neovim - Is there a way to overwrite vim's default command? - Stack Overflow #64

Open yaohunzhanyue opened 4 years ago

yaohunzhanyue commented 4 years ago

https://stackoverflow.com/questions/61100302/is-there-a-way-to-overwrite-vims-default-command

I want to map :bd to :bd! using:

command! -nargs=* -complete=buffer bd :call bd!

but vim told me "User defined commands must start with an uppercase letter"


update solutions from answer:

cnoremap bd bd!

another way

cnoreabbrev <expr> bd getcmdtype() == ":" && getcmdline() == 'bd' ? 'bd!' : 'bd'