summaryrefslogtreecommitdiff
path: root/.config/nvim/lua/dts/remap.lua
diff options
context:
space:
mode:
Diffstat (limited to '.config/nvim/lua/dts/remap.lua')
-rw-r--r--.config/nvim/lua/dts/remap.lua57
1 files changed, 57 insertions, 0 deletions
diff --git a/.config/nvim/lua/dts/remap.lua b/.config/nvim/lua/dts/remap.lua
new file mode 100644
index 0000000..f26b792
--- /dev/null
+++ b/.config/nvim/lua/dts/remap.lua
@@ -0,0 +1,57 @@
+vim.g.mapleader = ' '
+
+-- Allow moving of lines with Alt+j and Alt+k.
+vim.keymap.set("n", "<A-j>", ":m .+1<CR>==")
+vim.keymap.set("n", "<A-k>", ":m .-2<CR>==")
+vim.keymap.set("i", "<A-j>", "<Esc>:m .+1<CR>==gi")
+vim.keymap.set("i", "<A-k>", "<Esc>:m .-2<CR>==gi")
+vim.keymap.set("v", "<A-j>", ":m '>+1<CR>gv=gv")
+vim.keymap.set("v", "<A-k>", ":m '<-2<CR>gv=gv")
+
+-- Move between window splits with Ctrl+h, Ctrl+j, Ctrl+k, Ctrl+l
+vim.keymap.set("n", "<C-h>", ":wincmd h<CR>")
+vim.keymap.set("n", "<C-j>", ":wincmd j<CR>")
+vim.keymap.set("n", "<C-k>", ":wincmd k<CR>")
+vim.keymap.set("n", "<C-l>", ":wincmd l<CR>")
+vim.keymap.set("i", "<C-h>", "<Esc>:wincmd h<CR>")
+vim.keymap.set("i", "<C-j>", "<Esc>:wincmd j<CR>")
+vim.keymap.set("i", "<C-k>", "<Esc>:wincmd k<CR>")
+vim.keymap.set("i", "<C-l>", "<Esc>:wincmd l<CR>")
+
+-- Resize window splits with Ctrl+arrows.
+vim.keymap.set("n", "<C-Up>", ":resize +2<CR>")
+vim.keymap.set("n", "<C-Down>", ":resize -2<CR>")
+vim.keymap.set("n", "<C-Left>", ":vertical resize +2<CR>")
+vim.keymap.set("n", "<C-Right>", ":vertical resize -2<CR>")
+
+-- Keep cursor in the center of the window when doing half page jumping.
+vim.keymap.set("n", "<C-u>", "<C-u>zz")
+vim.keymap.set("n", "<C-d>", "<C-d>zz")
+
+-- Keep cursor in the center of the windows when moving through search results.
+vim.keymap.set("n", "n", "nzzzv")
+vim.keymap.set("n", "N", "Nzzzv")
+
+-- Stops replaced test from been copied. Preserves what was originally yanked.
+vim.keymap.set("x", "<leader>p", [["_dP]])
+vim.keymap.set("n", "<leader>d", [["_d]])
+
+-- Append line below to end of current line and do not move cursor to the end of the line.
+vim.keymap.set("n", "J", "mzJ`z")
+
+-- Easy insertion of trailing ; or , in insert mode.
+vim.keymap.set("i", ";;", "<Esc>A;")
+vim.keymap.set("i", ",,", "<Esc>A,")
+
+-- Allow yanking into system clipboard.
+vim.keymap.set({"n", "v"}, "<leader>y", [["+y]])
+vim.keymap.set("n", "<leader>Y", [["+Y]])
+
+-- Globally replace word that cursor is on.
+vim.keymap.set("n", "<leader>s", [[:%s/\<<C-r><C-w>\>/<C-r><C-w>/gI<Left><Left><Left>]])
+
+-- Toggle hidden characters.
+vim.keymap.set("n", "<leader>l", function()
+ vim.opt.list = not(vim.opt.list:get())
+end)
+