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

twitter logo github logo ・1 min read

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

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.

twitter logo DISCUSS
Classic DEV Post from Apr 1

What's your favorite coding joke/comic etc?

Let's have them! ...

Daisuke Mino profile image
I am "the" Vulnerability.

Sore eyes?

dev.to now has dark mode.

Go to the "misc" section of your settings and select night theme ❤️

(There is also a pink mode)