From 8fd31a960366f01c1b6048cf1c5e1979aa9afea6 Mon Sep 17 00:00:00 2001 From: Price Hiller Date: Sun, 20 Aug 2023 04:50:15 -0500 Subject: [PATCH] feat(nvim): add keybind to insert inversed expandtab character(s) --- dots/.config/nvim/lua/core/mappings.lua | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/dots/.config/nvim/lua/core/mappings.lua b/dots/.config/nvim/lua/core/mappings.lua index c200a860..f2a87f21 100755 --- a/dots/.config/nvim/lua/core/mappings.lua +++ b/dots/.config/nvim/lua/core/mappings.lua @@ -62,6 +62,16 @@ M.setup = function() -- Buffer bindings vim.keymap.set("n", "", ":bprevious", { silent = true, desc = "Go to Previous Buffer" }) vim.keymap.set("n", "", ":bnext", { silent = true, desc = "Go to Next Buffer" }) + + -- Binding to insert literal tab + vim.keymap.set("i", "", function() + if vim.opt_local.expandtab:get() then + vim.api.nvim_feedkeys("\t", "m", false) + else + local spaces = string.rep(" ", vim.opt_local.shiftwidth:get() or 4) + vim.api.nvim_feedkeys(spaces, "m", false) + end + end, { silent = true, desc = "Insert Literal Tab" }) end return M