In my init.vim
, I have the following:
ca WQ wq
What would be the equivalent in my init.lua
?
Vi and Vim Stack Exchange is a question and answer site for people using the vi and Vim families of text editors. It only takes a minute to sign up.
Sign up to join this community!!Note: this solution only works on Neovim >= v0.10; see @ruuter's answer if you are on an older version of neovim.
Command abbreviation is treated as just another keymap mode by nvim_set_keymap
. The equivalent of ca WQ wq
in lua is:
vim.keymap.set("ca", "WQ", "wq")
I had a hard time discovering this, as the help text in h: vim.keymap.set
/the lua.txt
help file does not actually list out the modes! It does however tell you to see h: nvim_set_keymap
which lives in the api.txt
help file, and that's where abbreviations are mentioned!
Shortname is too long
error. Instead this you can simply do vim.cmd('ca WQ wq')
. Use vim.cmd
to execute any vim command in lua script.
You can execute any vim script command with vim.cmd
. So in your case:
vim.cmd('ca WQ wq')