21

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 verse. Is it possible to have Vi automatically load into Insert Mode rather than Normal Mode?

  • 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 '15 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 '15 at 7:59
  • 3
    That tag is confusing me. If this question is about "original vi", why is a vim answer accepted? – muru Feb 6 '15 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. – 200_success Feb 6 '15 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? – Martin Tournoij Feb 6 '15 at 8:22
30

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
14
$ 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

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.

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

It can be started to insert mode by -i option. You can alias it using the following in your .bashrc in order to start in insert mode automatically every time:

alias vi="vi -i"
  • -i does not start insert mode – Christian Brabandt Aug 27 '15 at 6:21
  • -i is for setting the viminfo file name, not for starting in insert mode. – user579 Sep 13 '18 at 11:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy