What
Add a BufEnter/WinEnter autocmd that automatically switches to insert (terminal) mode whenever the cursor lands in a terminal buffer. This removes the need to press i every time you return to the <leader>, terminal split.
Where
lua/config/options.lua — near the existing terminal keymap (<leader>, and <Esc><Esc> at lines 20–21).
Why it matters
The config opens a terminal with <leader>, and exits terminal mode with <Esc><Esc>. The missing ergonomic link is re-entry: after switching to another window and back, you always have to press i to resume typing. With H/L buffer cycling and <C-w> window switching both active, re-entering insert mode manually gets repetitive.
Suggested implementation
vim.api.nvim_create_autocmd({ "BufEnter", "WinEnter" }, {
callback = function()
if vim.bo.buftype == "terminal" then
vim.cmd("startinsert")
end
end,
})
Notes
- This does not affect
<Esc><Esc> — that keymap exits terminal mode to normal mode within the terminal buffer, and the autocmd only fires on buffer/window enter, not on mode changes.
- If the terminal is used for reading output (e.g. after
:Compile), the auto-insert can be briefly annoying. A guard like if vim.fn.mode() ~= 'n' then return end or a buffer-local opt-out (similar to the format-on-save toggle pattern) could mitigate this.
What
Add a
BufEnter/WinEnterautocmd that automatically switches to insert (terminal) mode whenever the cursor lands in a terminal buffer. This removes the need to pressievery time you return to the<leader>,terminal split.Where
lua/config/options.lua— near the existing terminal keymap (<leader>,and<Esc><Esc>at lines 20–21).Why it matters
The config opens a terminal with
<leader>,and exits terminal mode with<Esc><Esc>. The missing ergonomic link is re-entry: after switching to another window and back, you always have to pressito resume typing. WithH/Lbuffer cycling and<C-w>window switching both active, re-entering insert mode manually gets repetitive.Suggested implementation
Notes
<Esc><Esc>— that keymap exits terminal mode to normal mode within the terminal buffer, and the autocmd only fires on buffer/window enter, not on mode changes.:Compile), the auto-insert can be briefly annoying. A guard likeif vim.fn.mode() ~= 'n' then return endor a buffer-local opt-out (similar to the format-on-save toggle pattern) could mitigate this.