Lua script
An arbitrary vim command can be executed with
vim.cmd('echo 17+25')
vim.fn
can be used to call vim functions:
vim.print( vim.fn.printf('x = %d', 42) )
I believe the following Lua expression performs the same as the vim :inoremap jj <esc>:w<cr>
(but comare with vim.keymap.set(…)
).
vim.api.nvim_set_keymap('i', 'jj', '<esc>:w<cr>', {noremap=true})
Variables
Variables can be accessed like so:
vim.g | Global variables |
vim.b | Current buffer |
vim.w | Current window |
vim.t | Current tab-page |
vim.v | Predefined vim variable |
vim.env | Environment variable |
Options
| Like |
vim.opt | :set |
vim.opt_global | :setglobal |
vim.opt_local | :setlocal |
Multiple («map like») values can be assigned like so
vim.opt.wildignore = { '*.o', '*.a', '__pycache__' }
vim.opt.listchars = { space = '_', tab = '>~' }
vim.opt.formatoptions = { n = true, j = true, t = true }
TODO: Compare vim.print(vim.o.smarttab)
and vim.print(vim.opt.smarttab)
.
TODO
ctrl-q
starts visual block selection. Thus ctrl-v
can still be used for pasting text.
vim.api.nvim_create_autocmd()
nvim_create_autocmd