From 280c00b272470e23fda2396e1580d095725741d6 Mon Sep 17 00:00:00 2001 From: "Kenneth Benzie (Benie)" Date: Mon, 2 Feb 2026 20:30:41 +0000 Subject: [PATCH] Add keymap to format whole file with gw Introduces `gw` to format the entire buffer using the internal formatting operator gw. It preserves the current window view (cursor position and scroll) during the operation. --- plugin/mappings.lua | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/plugin/mappings.lua b/plugin/mappings.lua index bcbcfdd..7c02947 100644 --- a/plugin/mappings.lua +++ b/plugin/mappings.lua @@ -50,3 +50,10 @@ vim.keymap.set('v', 'rg', ":'<,'>Rg", opts) -- Mapping to toggle checkboxes vim.keymap.set('n', '', ':CheckboxToggle', opts) + +-- Format whole file using internal algorithm +vim.keymap.set('n', 'gw', function() + local view = vim.fn.winsaveview() + vim.cmd('normal! gggwG') + vim.fn.winrestview(view) +end, { desc = 'Format whole file with gw' })