From 0e2060752fa22ab14dfd52101fe7b25baf39d4af Mon Sep 17 00:00:00 2001 From: Joe Date: Sun, 16 Jun 2024 16:44:30 +0200 Subject: up --- .config/nvim/lua/hooks.lua | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to '.config/nvim/lua') diff --git a/.config/nvim/lua/hooks.lua b/.config/nvim/lua/hooks.lua index 0d5ed32..eaf0687 100644 --- a/.config/nvim/lua/hooks.lua +++ b/.config/nvim/lua/hooks.lua @@ -1,4 +1,8 @@ vim.api.nvim_create_autocmd({"BufWritePre"}, { pattern = "*", - command = [[%s/\s\+$//e]], + callback = function(ev) + save_cursor = vim.fn.getpos(".") + vim.cmd([[%s/\s\+$//e]]) + vim.fn.setpos(".", save_cursor) + end, }) -- cgit v1.2.3