How do I start vim in insert mode?

Vim

Vim Problem Overview


Whenever I enter vim, there are 99% chance that I will go in insert mode and edit the file. Can I make vim always start in insert mode?

Vim Solutions


Solution 1 - Vim

You can start vim like this:

vim -c 'startinsert' FILENAME

If you want, you can edit the .bashrc file (if you are using bash) and add this line:

alias vim="vim -c 'startinsert'"

Solution 2 - Vim

You can use vim +star, which is even shorter. NB: star is short for :help :start.

If you want this behavior by default, the best option is to add the line

autocmd BufRead,BufNewFile * start

into your ~/.vimrc. Also take a look at :h 'insertmode', which outlines a special option made for this kind of functionality. However, it can make it difficult to get out of insert mode which is crucial for growing in your vim ninja skills.

Solution 3 - Vim

You can, and it's very simple.

The :startinsert command enters insert mode. (It is the exact command-line-mode counterpart to typing i in normal-mode.) Just drop it into your vimrc so it runs at startup. Unlike some of the other suggestions, this doesn't interfere with dropping back to normal-mode by ESC as normal.

Solution 4 - Vim

Additionally, there's something called "Easy mode", started from vim -y or evim. It's a more radical departure than just starting in insert mode: it has some key bindings matching other editors', and normal-mode commands are done by hitting Ctrl+O instead of Esc. As a consequence of that, being in insert mode is the rule rather than the exception.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionSantosh KumarView Question on Stackoverflow
Solution 1 - VimperrealView Answer on Stackoverflow
Solution 2 - VimConnerView Answer on Stackoverflow
Solution 3 - VimNentuabyView Answer on Stackoverflow
Solution 4 - VimechristophersonView Answer on Stackoverflow