85

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?

6
  • 19
    Really? The only time I would want to start in insert mode is when I open a blank file for the first time. Every time after that I'm more likely to need to first navigate to somewhere else in the file. You really insert text on the first line 99% of the time you open a file? Commented Jul 13, 2012 at 6:25
  • 3
    @lwburk I have habit of using GUI based editors.. and currently I use down-arrow to navigate. Commented Jul 13, 2012 at 10:23
  • 15
    with every other text editor (I challenge you to give another example!), if you open a file, move the cursor and start typing, what you type appears in the file. For most people who weren’t brought up on vim, this is a well established (and time saving) habit. With vim, however, the results of doing this are somewhat random - typically what you type will move you around a bit, accidentally switch to insert mode and the rest of what you type gets inserted in some random spot. Sometimes you delete stuff. To work out what happened takes a moment, and you often miss something. Commented Oct 8, 2012 at 23:39
  • 5
    @lwburk That isn't true when writing git commit messages :) Commented Feb 24, 2013 at 13:17
  • 4
    +1 This is really useful for streamlining writing commit messages. In this case, the file needs to be prepended and further lines are only informational. Commented Jan 6, 2014 at 16:29

4 Answers 4

71

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'"

Sign up to request clarification or add additional context in comments.

5 Comments

This only worked for me after removing the single quotes around startinsert, otherwise vim loads complaining about not finding a mark. This is for gvim on windows.
That's because single quotes don't work like that on windows.
I used this to instantly start typing when committing in git: git config --global core.editor "vim -c 'startinsert'"
can you do this in .vimrc ?
@DanielBöhmer Almost years later that is exactly why I was looking for this and it still works today.
49

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.

3 Comments

This should be the accepted answer in my opinion, because it does not depend on bash's config files, which might be relevant when running gvim with an non-interactive, no-login shell (-c).
If you want to make it the standard all the time, you should add VimEnter to the event list, this way it still works if you just call vim without any arguments.
that's honestly a bad/dysfunctional way to get at what the OP is asking for, because it just starts in insert mode when you start typing...or at least that's how it behaves when i try it. It's better just to let the program start in normal mode because that's how you take advantage of all the search and navigation features.
26

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.

2 Comments

vim +star also doesn't interfere with dropping back to normal-mode
this works just like the autocmd hack above, but the problem is that neither one explicitly tells you that you are in insert mode at the bottom unlike when you switch to insert mode, so i would not recommend putting either of these things in the .vimrc file
13

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.

5 Comments

+1 I think, reading form the OP, this is most likely what he was after. Essentially: he wants something not-vim. Or, at least, less-vim.
Whoa, 'easy mode' is weird. And hard to quit. blog.tommorris.org/post/1230874385/…
I tried easy mode but have no idea how to quit it. The blog post linked above is now a 404.
@TaylorEdmiston True, the post is gone and I can't find it in the Wayback Machine. But, to quit, you'd do C-o : q RETURN.
HOW TO QUIT VIM EASY MODE. HELP !!1

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.