local map = vim.keymap.set -- Switch windows with map("n", "", "j") map("n", "", "k") map("n", "", "h") map("n", "", "l") -- Never use the arrow keys for _, key in ipairs({ "", "", "", "" }) do map({ "n", "i" }, key, "") end -- Disable ex mode map("n", "Q", "") -- Expand :git to fugitive's :Git, but only as a whole command. -- (No Lua-native abbreviation API exists, so this stays a thin vim.cmd call.) vim.cmd([[cnoreabbrev git (getcmdtype() ==# ':' && getcmdline() ==# 'git') ? 'Git' : 'git']]) -- Note: the vimrc's `w!!` sudo-save abbreviation is deliberately NOT ported -- here — its own comment says it doesn't work under Neovim (sudo can't -- prompt for a password there). -- Append modeline when pressing ml local function append_modeline() local modeline = string.format( " vim: set ts=%d sw=%d tw=%d %set :", vim.bo.tabstop, vim.bo.shiftwidth, vim.bo.textwidth, vim.bo.expandtab and "" or "no" ) modeline = vim.bo.commentstring:gsub("%%s", modeline) vim.api.nvim_buf_set_lines(0, -1, -1, false, { modeline }) end map("n", "ml", append_modeline, { silent = true })