diff options
| author | 2026-09-10 22:25:18 +0200 | |
|---|---|---|
| committer | 2026-09-10 22:25:18 +0200 | |
| commit | d8beb7892e78474511899202972a145e8fbb9762 (patch) | |
| tree | a6a6669bbb773054abb82e534e2ebd3553eb0974 /neovim/.config | |
| parent | cd3b426b15ace7d35c71bdee593163e09994c76f (diff) | |
| download | dotfiles-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.lua | 10 |
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 @@ | |||
| 1 | local map = vim.keymap.set | 1 | local 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. | ||
| 4 | map("n", "<C-j>", "<C-w>j") | 8 | map("n", "<C-j>", "<C-w>j") |
| 5 | map("n", "<C-k>", "<C-w>k") | 9 | map("n", "<C-k>", "<C-w>k") |
| 6 | map("n", "<C-h>", "<C-w>h") | 10 | map("n", "<C-h>", "<C-w>h") |
| 7 | map("n", "<C-l>", "<C-w>l") | 11 | map("n", "<C-l>", "<C-w>l") |
| 12 | map("t", "<C-j>", [[<C-\><C-n><C-w>j]]) | ||
| 13 | map("t", "<C-k>", [[<C-\><C-n><C-w>k]]) | ||
| 14 | map("t", "<C-h>", [[<C-\><C-n><C-w>h]]) | ||
| 15 | map("t", "<C-l>", [[<C-\><C-n><C-w>l]]) | ||
| 8 | 16 | ||
| 9 | -- Never use the arrow keys | 17 | -- Never use the arrow keys |
| 10 | for _, key in ipairs({ "<Up>", "<Down>", "<Left>", "<Right>" }) do | 18 | for _, key in ipairs({ "<Up>", "<Down>", "<Left>", "<Right>" }) do |
