1
0
Fork 0

basic keymaps

This commit is contained in:
zymon 2024-08-25 14:51:46 +02:00
parent 699291f9ae
commit 06e9e0a9c4
2 changed files with 40 additions and 0 deletions

View file

@ -13,3 +13,4 @@ vim.opt.rtp:prepend(lazypath)
require("znvim.options") require("znvim.options")
require("lazy").setup("znvim.plugins") require("lazy").setup("znvim.plugins")
require("znvim.keymaps")

39
lua/znvim/keymaps.lua Normal file
View file

@ -0,0 +1,39 @@
vim.keymap.set("i", "jk", "<ESC>")
vim.keymap.set("n", "<leader>pl", "<cmd>Lazy<cr>", { desc = "Lazy" })
vim.keymap.set("n", "<leader>uc", function ()
if #vim.o.colorcolumn == 0 then
vim.o.colorcolumn = "80"
else
vim.o.colorcolumn = ""
end
end, { desc = "toggle 80th column" })
vim.keymap.set("n", "<leader>ur", function ()
if vim.o.relativenumber then
vim.o.relativenumber = false
else
vim.o.relativenumber = true
end
end, { desc = "toggle relative numbers" })
vim.keymap.set("n", "<C-A-k>", "<cmd>m .-2<cr>==", { desc = "move up" })
vim.keymap.set("n", "<C-A-j>", "<cmd>m .+1<cr>==", { desc = "move line down" })
vim.keymap.set("i", "<C-A-k>", "<Esc><cmd>m .-2<cr>==gi", { desc = "move up" })
vim.keymap.set("i", "<C-A-j>", "<Esc><cmd>m .+1<cr>==gi", { desc = "move line down" })
vim.keymap.set("v", "<C-A-j>", ":m '>+1<CR>gv=gv", { desc = "move lines up" })
vim.keymap.set("v", "<C-A-k>", ":m '<-2<CR>gv=gv", { desc = "move lines down"})
vim.keymap.set({ "i", "n" }, "<esc>", "<cmd>noh<cr><esc>", { desc = "clear hlsearch" })
-- replace word under the cursor
vim.keymap.set("n", "<leader>ss", [[:%s/\<<C-r><C-w>\>/<C-r><C-w>/gI<Left><Left><Left>]])
vim.keymap.set("x", "<leader>P", "\"_dP", { desc = "delete into void register and paste" })
vim.keymap.set("n", "<S-h>", "<cmd>bprevious<cr>", { desc = "prev buffer" })
vim.keymap.set("n", "<S-l>", "<cmd>bnext<cr>", { desc = "next buffer" })
vim.keymap.set("n", "[b", "<cmd>bprevious<cr>", { desc = "prev buffer" })
vim.keymap.set("n", "]b", "<cmd>bnext<cr>", { desc = "next buffer" })