I want to use <S-Tab> to do the reverse of <Tab> in insert mode in Lua. (If this is complicated in Lua then VimScript is OK) How?


Is <C-d> what you want? :h i_CTRL-D

CTRL-D      Delete one shiftwidth of indent at the start of the current
        line.  The indent is always rounded to a 'shiftwidth' (this is
        vi compatible).

If so

inoremap <S-Tab> <C-d>
vim.api.nvim_set_keymap('i', '<S-Tab>', "v:lua.check_back_space() ? '<BS>' : '<NOP>'", EXPR_NOREF_NOERR_TRUNC)

where EXPR_... is

local EXPR_NOREF_NOERR_TRUNC = { expr = true, noremap = true, silent = true, nowait = true }

and check_back_space can be implemented easily.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.