I have the following mappings to make it easy to move out of a terminal pane in Neovim:
tnoremap <C-h> <C-\><C-n><C-w>h
" Workaround since <C-h> isn't working in Neovim right now
tnoremap <C-w>h <C-\><C-n><C-w>h
tnoremap <C-j> <C-\><C-n><C-w>j
tnoremap <C-k> <C-\><C-n><C-w>k
tnoremap <C-l> <C-\><C-n><C-w>l
The only problem is that when I move back into the terminal pane, I have to press i to get back into insert mode. I always want it to be in insert mode when I move into a Neovim pane that is running terminal. What's the best way to achieve this?
BufEnterautocmd looks like it does not have this problem. – Rastapopoulos Apr 19 '18 at 10:49silent! normal i. – Cookie04 Aug 18 '23 at 18:57
– Will Munn Sep 07 '23 at 13:50vim.api.nvim_create_autocmd({ "TermOpen", "WinEnter term://*" }, { command = "startinsert" })Invalid 'event': 'WinEnter term://*'– robertspierre Feb 06 '24 at 15:54vim.api.nvim_create_autocmd({ "TermOpen", "WinEnter" }, { pattern = "term://*", command = "startinsert" })– ChrisG Mar 06 '24 at 17:04