26

I use Vi as my preferred (and, in fact, only) text editor on Linux Systems. I know how to change modes from normal to insert, and vice-versa.

Is it possible to have Vi automatically load into Insert Mode rather than Normal Mode?

I want this because I can only access my Linux over SSH, and my computer that I can use for SSH access is so slow, it takes ages to load command mode. (Also my Openwrt system is quite slow).

6
  • 1
    @Earthliŋ - Because I can only access my Linux over SSH, and my computer that I can use for SSH access is *so* slow, it takes *ages* to load command mode. (Also my Openwrt system is quite slow).
    – user254
    Feb 4, 2015 at 7:45
  • 3
    Thanks. Why don't you add this info to the question body? This way the question makes much more sense (to me at least) and will be easier findable (e.g. by searching "vim command mode slow to load").
    – Earthliŋ
    Feb 4, 2015 at 7:59
  • 4
    That tag is confusing me. If this question is about "original vi", why is a vim answer accepted?
    – muru
    Feb 6, 2015 at 8:00
  • 2
    @muru Agreed. Changing the question two days afterwards, even if it was originally misinterpreted, makes a mess. At this point, it would be better to change the question to Vim and ask another question for Original Vi. I've voted to close as "Unclear what you are asking", and I would be glad to retract it if reverted. Feb 6, 2015 at 8:04
  • 3
    I've reverted the tag; this question can stay open, the OP can ask a new question .... IMHO that's the easier ... Also, I think the the OP uses nvi? Feb 6, 2015 at 8:22

3 Answers 3

38

You can use the +startinsert option (or +star for short) to start Vim with insert mode.

vim +star myfile.txt

If you want this to happen by default when starting Vim, you can make an alias (in your .bashrc or .zshrc for example) as follows:

alias vim="vim +startinsert"

However, that works only when starting Vim. If you want Vim to be in Insert mode even when you open a file from within Vim, add the following to your .vimrc:

au BufRead,BufNewFile * startinsert
16
$ vim -y <file>

-y Easy mode. Implied for |evim| and |eview|. Starts with 'insertmode' set and behaves like a click-and-type editor. This sources the script $VIMRUNTIME/evim.vim. Mappings are set up to work like most click-and-type editors, see |evim-keys|. The GUI is started when available. {not in Vi}

source

0
5

Although I think starting in insert mode is not the vim way, you can do this very easily. You should start vim with

vim -c startinsert 'file'

The -c flag passes in a command into vim. The :startinsert command changes to insert mode. As you can imagine, you could start vim with any number of commands if you so desired.

1
  • Does this only work with Vim, or does it work also on Vi (My Openwrt system only has Vi).
    – user254
    Feb 4, 2015 at 16:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.