local opts = { noremap = true, silent = true } -- Shorten function name local keymap = vim.keymap.set --Remap space as leader key keymap("", "", "", opts) vim.g.mapleader = " " vim.g.maplocalleader = " " ---Autocompile and Execute --ANSI C vim.cmd([[autocmd BufEnter *.c map :w :!gcc % -ansi -o %< && ./%< ]]) --C99 vim.cmd([[autocmd BufEnter *.c map :w :!gcc -std=c99 % -o %< && ./%< ]]) --C vim.cmd([[autocmd BufEnter *.c map :w :!gcc % -o %< && ./%< ]]) --C++ vim.cmd([[autocmd BufEnter *.cpp map :w :!g++ % -o %< && ./%< ]]) -- Modes -- normal_mode = "n", -- insert_mode = "i", -- visual_mode = "v", -- visual_block_mode = "x", -- command_mode = "c", -- Normal -- -- -- --Save file with Ctrl+S keymap("n", "", ":w", opts) --Toggle nvim-tree keymap("n", "", ":NvimTreeToggle", opts) --Disable C-e keymap("n", "", ":", opts) -- Better window navigation for split keymap("n", "", "h", opts) keymap("n", "", "j", opts) keymap("n", "", "k", opts) keymap("n", "", "l", opts) -- Resize with arrows keymap("n", "", ":resize +2", opts) keymap("n", "", ":resize -2", opts) keymap("n", "", ":vertical resize +2", opts) keymap("n", "", ":vertical resize -2", opts) -- Move text up and down(better implementation in visual mode) --keymap("n", "", ":m .+1==gi", opts) --keymap("n", "", ":m .-2==gi", opts) -- Insert -- -- Visual -- -- Stay in indent mode keymap("v", "<", "", ">gv", opts) -- Move text up and down keymap("v", "", ":m .+1==", opts) keymap("v", "", ":m .-2==", opts) keymap("v", "p", '"_dP', opts) -- Visual Block -- -- Move text up and down keymap("x", "J", ":move '>+1gv-gv", opts) keymap("x", "K", ":move '<-2gv-gv", opts) keymap("x", "", ":move '>+1gv-gv", opts) keymap("x", "", ":move '<-2gv-gv", opts)