Skip to content

Commit

Permalink
refactor(map): use C-c to clear hlsearch and escape
Browse files Browse the repository at this point in the history
  • Loading branch information
pwnwriter committed Nov 11, 2024
1 parent 0b67897 commit d833666
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions lua/mappings.lua
Original file line number Diff line number Diff line change
Expand Up @@ -12,34 +12,46 @@ local M = {}
M.map = map

M.general = function()
-- insert movement
map("i", "<C-h>", "<Left>")
map("i", "<C-j>", "<Down>")
map("i", "<C-k>", "<Up>")
map("i", "<C-l>", "<Right>")

-- Copy and paste in the same cursor position
map("n", "p", function()
local row, col = unpack(vim.api.nvim_win_get_cursor(0))
vim.cmd('put')
vim.api.nvim_win_set_cursor(0, { row + 1, col })
end)

map("i", "<C-l>", "<Right>")
map("i", "jj", "<esc>")
map("i", "<C-c>", "<esc>")

map("n", "<C-c>", "<cmd>noh<CR>")

-- Save only on new changes
map("n", "<C-s>", "<cmd>update<CR>")

-- Switching splits
map("n", "<C-h>", "<C-w>h")
map("n", "<C-j>", "<C-w>j")
map("n", "<C-k>", "<C-w>k")
map("n", "<C-l>", "<C-w>l")
map("n", "<C-s>", "<cmd>update<CR>")


map("n", "<Tab>", "<cmd>bnext<CR>")
map("n", "<s-Tab>", "<cmd>bprev<CR>")

-- Resize splits
map("n", "<A-k>", ":resize +2<CR>")
map("n", "<A-j>", ":resize -2<CR>")
map("n", "<A-h>", ":vertical resize +2<CR>")
map("n", "<A-l>", ":vertical resize -2<CR>")

map("n", "<C-d>", "<C-d>zz")
map("n", "<C-u>", "<C-u>zz")

map("v", "??", 'y:h <C-R>"<cr>"') -- Show vim help
map("v", "?/", 'y:/ <C-R>"<cr>"') -- Search across the buffer
end
Expand Down

0 comments on commit d833666

Please sign in to comment.