flake-update-20260201
 1-- Keymaps are automatically loaded on the VeryLazy event
 2-- Default keymaps: https://github.com/LazyVim/LazyVim/blob/main/lua/lazyvim/config/keymaps.lua
 3
 4local map = vim.keymap.set
 5
 6-- Quick escape and save
 7map("i", "jj", "<ESC>:w<CR>", { noremap = true, desc = "ESC and Save" })
 8map("i", "jk", "<ESC>", { noremap = true, desc = "ESC" })
 9
10-- Clear search highlight
11map("n", "<Esc>", "<cmd>nohlsearch<CR>", { desc = "Clear search highlight" })
12
13-- Quick quit
14map("n", "<C-q>", "<cmd>qa<CR>", { desc = "Quit all" })
15
16-- Change inner word with Ctrl-c
17map("n", "<C-c>", "ciw", { noremap = true, desc = "Change inner word" })
18
19-- Replace word under cursor
20map("n", "<Leader>cr", [[:%s/\<<C-r><C-w>\>//g<Left><Left>]], { noremap = true, desc = "Replace word under cursor" })
21
22-- Redo with U (more intuitive)
23map("n", "U", "<cmd>redo<CR>", { noremap = true, desc = "Redo" })
24
25-- Move to start/end of line (swap 0 and ^)
26map("n", "0", "^", { noremap = true, desc = "Move to first non-blank" })
27map("n", "^", "0", { noremap = true, desc = "Move to start of line" })
28map("v", "0", "^", { noremap = true, desc = "Move to first non-blank" })
29map("v", "^", "0", { noremap = true, desc = "Move to start of line" })
30map("v", "$", "g_", { noremap = true, desc = "Move to last non-blank" })
31
32-- Copy line up/down
33map("n", "zj", 'mz"yyy"yP`z', { noremap = true, desc = "Copy line down" })
34map("n", "zk", 'mz"yyy"yP`zk', { noremap = true, desc = "Copy line up" })
35
36-- Select last paste
37map("n", "gp", "`[v`]", { noremap = true, desc = "Select last paste" })
38
39-- Put text before/after line
40map("n", "go", "<cmd>put<CR>", { noremap = true, desc = "Put text after line" })
41map("n", "gO", "<cmd>put!<CR>", { noremap = true, desc = "Put text before line" })
42
43-- Word navigation with Ctrl+Arrow
44map("n", "<C-Left>", "B", { noremap = true, desc = "Previous word" })
45map("n", "<C-Right>", "e", { noremap = true, desc = "End of word" })
46map("i", "<C-Left>", "<C-o>B", { noremap = true, desc = "Previous word" })
47map("i", "<C-Right>", "<C-o>W", { noremap = true, desc = "Next word" })
48
49-- Remove trailing whitespace
50map("n", "<Leader>cw", [[:%s/\s\+$//e<cr>]], { noremap = true, desc = "Remove trailing whitespace" })
51
52-- Surround with double quote in visual mode
53map("v", '"', 's"<C-r>""<Esc>', { noremap = true, silent = true, desc = "Surround with quotes" })
54
55-- CD to current file directory
56map("n", "<leader>C", "<cmd>cd %:h<cr>", { noremap = true, desc = "CD to current dir" })
57
58-- Mini.files (if installed)
59map("n", "<leader>e", function()
60  local ok, mini_files = pcall(require, "mini.files")
61  if ok then
62    mini_files.open(vim.api.nvim_buf_get_name(0), true)
63  end
64end, { desc = "Open mini.files", noremap = true })