Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I start vim in insert mode?

Tags:

vim

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?

like image 659
Santosh Kumar Avatar asked Jul 13 '12 04:07

Santosh Kumar


People also ask

How do I change Vim modes?

Changing the modesThe most commonly used command to enter in to insert mode is “i”. To shift back to normal mode, press Esc. To switch to the visual mode from Normal mode, different commands are v, V, Shift + v, and Ctrl + v. The most commonly used command to enter in to insert mode is “v”.

How do I start Vim in normal mode?

By default, Vim starts in “normal” mode. Normal mode can be accessed from other modes by pressing Esc or <C-[> .


2 Answers

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

like image 69
perreal Avatar answered Oct 05 '22 07:10

perreal


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.

like image 42
Conner Avatar answered Oct 05 '22 08:10

Conner