aboutsummaryrefslogtreecommitdiffstats
path: root/neovim/.config
diff options
context:
space:
mode:
authorGravatar Tom van der Lee <t0m.vd.l33@gmail.com>2026-09-10 22:25:18 +0200
committerGravatar Tom van der Lee <t0m.vd.l33@gmail.com>2026-09-10 22:25:18 +0200
commitd8beb7892e78474511899202972a145e8fbb9762 (patch)
treea6a6669bbb773054abb82e534e2ebd3553eb0974 /neovim/.config
parentcd3b426b15ace7d35c71bdee593163e09994c76f (diff)
downloaddotfiles-d8beb7892e78474511899202972a145e8fbb9762.tar.gz
dotfiles-d8beb7892e78474511899202972a145e8fbb9762.tar.bz2
dotfiles-d8beb7892e78474511899202972a145e8fbb9762.zip
Make <C-hjkl> window nav work from terminal buffers too
<C-w><direction> only works in Normal mode; a terminal buffer (e.g. claude-code.nvim's split) is in Terminal mode by default, where keystrokes go straight to the running process instead of Neovim. Add terminal-mode versions of the existing <C-hjkl> mappings that escape to Normal mode (<C-\><C-n>) before running the window command, so leaving a terminal split works the same one-chord way as moving between any other windows. Deliberately not mapping <Esc> to escape terminal mode (the vimrc had this commented out too) - many programs run inside a terminal buffer (claude included) and need to receive a real Escape keypress.
Diffstat (limited to 'neovim/.config')
-rw-r--r--neovim/.config/nvim/lua/config/keymaps.lua10
1 files changed, 9 insertions, 1 deletions
diff --git a/neovim/.config/nvim/lua/config/keymaps.lua b/neovim/.config/nvim/lua/config/keymaps.lua
index f0bfbec..66e97a0 100644
--- a/neovim/.config/nvim/lua/config/keymaps.lua
+++ b/neovim/.config/nvim/lua/config/keymaps.lua
@@ -1,10 +1,18 @@
1local map = vim.keymap.set 1local map = vim.keymap.set
2 2
3-- Switch windows with <C-[direction]> 3-- Switch windows with <C-[direction]>, from Normal mode or from inside a
4-- terminal buffer (e.g. claude-code.nvim's split) without leaving it first.
5-- Terminal mode passes keys straight to the running process by default, so
6-- <C-w><direction> alone never reaches Neovim there - <C-\><C-n> escapes to
7-- Normal mode before running the window command.
4map("n", "<C-j>", "<C-w>j") 8map("n", "<C-j>", "<C-w>j")
5map("n", "<C-k>", "<C-w>k") 9map("n", "<C-k>", "<C-w>k")
6map("n", "<C-h>", "<C-w>h") 10map("n", "<C-h>", "<C-w>h")
7map("n", "<C-l>", "<C-w>l") 11map("n", "<C-l>", "<C-w>l")
12map("t", "<C-j>", [[<C-\><C-n><C-w>j]])
13map("t", "<C-k>", [[<C-\><C-n><C-w>k]])
14map("t", "<C-h>", [[<C-\><C-n><C-w>h]])
15map("t", "<C-l>", [[<C-\><C-n><C-w>l]])
8 16
9-- Never use the arrow keys 17-- Never use the arrow keys
10for _, key in ipairs({ "<Up>", "<Down>", "<Left>", "<Right>" }) do 18for _, key in ipairs({ "<Up>", "<Down>", "<Left>", "<Right>" }) do