diff options
| author | Christoph Schlosser <christoph@linux.com> | 2025-03-16 00:10:38 +0100 |
|---|---|---|
| committer | Christoph Schlosser <christoph@linux.com> | 2025-03-16 00:10:38 +0100 |
| commit | 83cb1dff1464268b527ad3a26f4515f871d036d1 (patch) | |
| tree | 3573b230d95b1c21b699b8fd16fc12454d7c522a | |
| parent | caaa902fc1aa225e23a066cb5cd669a68a721f6c (diff) | |
| download | dots-83cb1dff1464268b527ad3a26f4515f871d036d1.tar.gz | |
nvim: Disable arrow keys in normal mode
| -rw-r--r-- | nvim/lua/keymaps.lua | 54 |
1 files changed, 37 insertions, 17 deletions
diff --git a/nvim/lua/keymaps.lua b/nvim/lua/keymaps.lua index 22d7796..7e7ba03 100644 --- a/nvim/lua/keymaps.lua +++ b/nvim/lua/keymaps.lua @@ -1,28 +1,48 @@ -- [[ Basic Keymaps ]] +-- See `:help vim.keymap.set()` --- Keymaps for better default experience --- See `:help vim.keymap.set()` -vim.keymap.set({ 'n', 'v' }, '<Space>', '<Nop>', { silent = true }) +-- Clear highlights on search when pressing <Esc> in normal mode +-- See `:help hlsearch` +vim.keymap.set('n', '<Esc>', '<cmd>nohlsearch<CR>') --- Remap for dealing with word wrap -vim.keymap.set('n', 'k', "v:count == 0 ? 'gk' : 'k'", { expr = true, silent = true }) -vim.keymap.set('n', 'j', "v:count == 0 ? 'gj' : 'j'", { expr = true, silent = true }) +-- Diagnostic keymaps +vim.keymap.set('n', '<leader>q', vim.diagnostic.setloclist, { desc = 'Open diagnostic [Q]uickfix list' }) + +-- Exit terminal mode in the builtin terminal with a shortcut that is a bit easier +-- for people to discover. Otherwise, you normally need to press <C-\><C-n>, which +-- is not what someone will guess without a bit more experience. +-- +-- NOTE: This won't work in all terminal emulators/tmux/etc. Try your own mapping +-- or just use <C-\><C-n> to exit terminal mode +vim.keymap.set('t', '<Esc><Esc>', '<C-\\><C-n>', { desc = 'Exit terminal mode' }) + +-- TIP: Disable arrow keys in normal mode +vim.keymap.set('n', '<left>', '<cmd>echo "Use h to move!!"<CR>') +vim.keymap.set('n', '<right>', '<cmd>echo "Use l to move!!"<CR>') +vim.keymap.set('n', '<up>', '<cmd>echo "Use k to move!!"<CR>') +vim.keymap.set('n', '<down>', '<cmd>echo "Use j to move!!"<CR>') + +-- Keybinds to make split navigation easier. +-- Use CTRL+<hjkl> to switch between windows +-- +-- See `:help wincmd` for a list of all window commands +vim.keymap.set('n', '<C-h>', '<C-w><C-h>', { desc = 'Move focus to the left window' }) +vim.keymap.set('n', '<C-l>', '<C-w><C-l>', { desc = 'Move focus to the right window' }) +vim.keymap.set('n', '<C-j>', '<C-w><C-j>', { desc = 'Move focus to the lower window' }) +vim.keymap.set('n', '<C-k>', '<C-w><C-k>', { desc = 'Move focus to the upper window' }) --- [[ Highlight on yank ]] --- See `:help vim.highlight.on_yank()` -local highlight_group = vim.api.nvim_create_augroup('YankHighlight', { clear = true }) +-- [[ Basic Autocommands ]] +-- See `:help lua-guide-autocommands` + +-- Highlight when yanking (copying) text +-- Try it with `yap` in normal mode +-- See `:help vim.highlight.on_yank()` vim.api.nvim_create_autocmd('TextYankPost', { + desc = 'Highlight when yanking (copying) text', + group = vim.api.nvim_create_augroup('kickstart-highlight-yank', { clear = true }), callback = function() vim.highlight.on_yank() end, - group = highlight_group, - pattern = '*', }) --- Diagnostic keymaps -vim.keymap.set('n', '[d', vim.diagnostic.goto_prev, { desc = 'Go to previous diagnostic message' }) -vim.keymap.set('n', ']d', vim.diagnostic.goto_next, { desc = 'Go to next diagnostic message' }) -vim.keymap.set('n', '<leader>e', vim.diagnostic.open_float, { desc = 'Open floating diagnostic message' }) -vim.keymap.set('n', '<leader>q', vim.diagnostic.setloclist, { desc = 'Open diagnostics list' }) - -- vim: ts=2 sts=2 sw=2 et |