vim.api.nvim_create_autocmd({ "BufWritePre" }, { pattern = {"*"}, callback = function() local save_cursor = vim.fn.getpos(".") vim.cmd([[%s/\s\+$//e]]) vim.fn.setpos(".", save_cursor) end, }) vim.api.nvim_create_autocmd({"CmdlineLeave", "CmdlineChanged"}, { group = vim.api.nvim_create_augroup("SearchHighlight", { clear = true }), pattern = { "/", "\\?" }, callback = function() vim.cmd([[nnoremap :noh]]) end }) vim.api.nvim_create_autocmd("TextYankPost", { desc = "Highlight yanked text", group = vim.api.nvim_create_augroup("HighlightYank", { clear = true}), callback = function() vim.highlight.on_yank() end })