diff --git a/lua/keymaps.lua b/lua/keymaps.lua index cc194a6..75cea58 100644 --- a/lua/keymaps.lua +++ b/lua/keymaps.lua @@ -84,19 +84,12 @@ vim.keymap.set('n', '[', 'tabprevious', { desc = 'Previous vim.keymap.set('n', '\\', 'Neotree toggle', { desc = 'Toggle Neotree' }) vim.keymap.set('n', '0', 'ToggleTerm', { desc = 'Toggle Terminal' }) --- Define a function to wrap lines to 80 columns +-- Wraps document to specified column width vim.keymap.set('n', 'dw', function() - -- Save the current 'textwidth' setting - local current_tw = vim.o.textwidth - - -- Set 'textwidth' to 80 temporarily - vim.o.textwidth = 80 - - -- Reformat all lines in the buffer - vim.api.nvim_command 'normal! ggVGgq' - - -- Restore the original 'textwidth' - vim.o.textwidth = current_tw + local current_tw = vim.o.textwidth -- Save the current 'textwidth' setting + vim.o.textwidth = 80 -- Set 'textwidth' to 80 temporarily + vim.api.nvim_command 'normal! ggVGgq' -- Reformat all lines in the buffer + vim.o.textwidth = current_tw -- Restore the original 'textwidth' end, { desc = '[D]ocument [W]rap to 80 column width' }) -- vim: ts=2 sts=2 sw=2 et