Nvim : Add <Leader>' to toggle tab width.

This commit is contained in:
Dmitry Voronin 2024-03-08 20:28:40 +03:00
parent 9e69d19e00
commit 1028cb2d88

View file

@ -4,6 +4,24 @@ function bye()
vim.cmd[[qa!]] vim.cmd[[qa!]]
end end
function toggle_tab_width()
if vim.bo.shiftwidth == 2 then
vim.bo.shiftwidth = 4
vim.bo.tabstop = 4
vim.bo.softtabstop = 4
elseif vim.bo.shiftwidth == 4 then
vim.bo.shiftwidth = 8
vim.bo.tabstop = 8
vim.bo.softtabstop = 8
elseif vim.bo.shiftwidth == 8 then
vim.bo.shiftwidth = 2
vim.bo.tabstop = 2
vim.bo.softtabstop = 2
end
end
rekey_normal("<Leader>'", "<cmd>lua toggle_tab_width()<cr>")
-- Repeat previous command. -- Repeat previous command.
rekey_normal("<Leader>.", "@:") rekey_normal("<Leader>.", "@:")
rekey_visual("<Leader>.", "@:") rekey_visual("<Leader>.", "@:")