Add keymap to format whole file with gw
Introduces `<leader>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.
This commit is contained in:
@@ -50,3 +50,10 @@ vim.keymap.set('v', '<leader>rg', ":'<,'>Rg<CR>", opts)
|
||||
|
||||
-- Mapping to toggle checkboxes
|
||||
vim.keymap.set('n', '<leader><CR>', ':CheckboxToggle<CR>', opts)
|
||||
|
||||
-- Format whole file using internal algorithm
|
||||
vim.keymap.set('n', '<leader>gw', function()
|
||||
local view = vim.fn.winsaveview()
|
||||
vim.cmd('normal! gggwG')
|
||||
vim.fn.winrestview(view)
|
||||
end, { desc = 'Format whole file with gw' })
|
||||
|
||||
Reference in New Issue
Block a user