DEV Community

Cover image for Automatically switch to insert mode when focusing on terminal window in Vim8
Daisuke Mino
Daisuke Mino

Posted on • Updated on

Automatically switch to insert mode when focusing on terminal window in Vim8

autocmd BufWinEnter,WinEnter * if &buftype == 'terminal' | silent! normal i | endif
Enter fullscreen mode Exit fullscreen mode

According to :help Terminal-mode, startinsert doesn't work on terminal window.

In Terminal-Normal mode you can move the cursor around with the usual Vim commands, Visually mark text, yank text, etc. But you cannot change the contents of the buffer. The commands that would start insert mode, such as 'i' and 'a', return to Terminal-Job mode. The window will be updated to show the contents of the terminal. |:startinsert| is ineffective.

Top comments (0)