Run code when matching files are written.
Section: Lua autocommands
Create an autocmd
lua
lua
vim.api.nvim_create_autocmd("BufWritePost", {
pattern = "*.lua",
callback = function()
print("saved lua file")
end,
})Explanation
Neovim’s Lua API makes event handling cleaner than old Vimscript groups.
Learn the surrounding workflow
Compare similar commands or jump into common fixes when this command is part of a bigger troubleshooting path.
Related commands
Same sheet · prioritizing Lua autocommands