config/.config/nvim/lua/chris/keymaps.lua

51 lines
1.0 KiB
Lua

local opts = { noremap = true, silent = true }
local map = vim.api.nvim_set_keymap
-- set Space as leader key
map("n", "<Space>", "", opts)
vim.g.mapleader = " "
vim.g.maplocalleader = " "
-- NORMAL
-- Move text up and down
map("n", "<C-k>", "<ESC>:m .-2<CR>==", opts)
map("n", "<C-j>", "<ESC>:m .+1<CR>==", opts)
-- Copy/Paste
map("n", "<C-y>", '"+y', opts)
map("n", "<C-p>", '"+y', opts)
-- Save
map("n", "<C-s>", ":w<CR>", opts)
-- Switch between buffers
map("n", "<S-l>", ":CybuNext<CR>", opts)
map("n", "<S-h>", ":CybuPrev<CR>", opts)
-- center after up and down movements
map("n", "<C-u>", "<C-u>zz", opts)
map("n", "<C-d>", "<C-d>zz", opts)
-- INSERT
-- Easy exit insert mode
map("i", "jk", "<ESC>", opts)
-- Paste
map("i", "<C-p>", '"+y', opts)
-- Save
map("i", "<C-s>", "<ESC>:w<CR>a", opts)
-- VISUAL
-- Indenting
map("v", "<", "<gv", opts)
map("v", ">", ">gv", opts)
-- Move text up and down
map("v", "<C-j>", ":m .+1<CR>==<ESC>V", opts)
map("v", "<C-k>", ":m .-2<CR>==<ESC>V", opts)
-- Copy
map("v", "<C-y>", '"+y', opts)