Neovim tips and tricks

2023/09/18

From VimScript into Lua

This is my cheat sheet for migrating VimScript into Lua. Things I often forget. There are places to learn about Lua use in Neovim . But, for some reason, I could not find side-by-side examples of VimScript vs Lua for quick migration. So I decided to start my own.

VimScript Lua
:nmap abc :something vim.keymap.add({'n'}, 'abc', ':something), noremap will be with more in the first {}
let g:session_autosave = 'yes' vim.g.session_autosave = 'yes'
autocmd BufWrite *py :call DeleteTrailingWs() vim.api.nvim_create_autocmd({'BufWrite'}, {pattern={'*.py'}, command = ":call DeleteTrailingWs()"})
let splitbelow = 1 vim.opt.splitbelow = true
(any vimscript commands) vim.api.nvim_exec2([[ (any vimscript commands) ]])
" comment -- comment (oh, well)