Sign up ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Then I press [Enter] in insert mode, there is a new line. But cursor places in the very beginning of a line. What do I do to create new line with the same indentation as the current's?

share|improve this question
I recommend that you spend a little time Googling for 'vim configuration' or the like. There's a ton that you can set in your ~/.vimrc file. – Telemachus Jan 23 '10 at 21:24
and that's how google takes me to here. – Apr 28 '14 at 13:02

3 Answers 3

up vote 13 down vote accepted

Adding set autoindent to your ~/.vimrc can do that for you automagically.

share|improve this answer
thanks! there was no .vimrc, is it ok to create a new one? – valya Jan 23 '10 at 21:13
yes, under your home directory. – John T Jan 23 '10 at 21:15

I'd also suggest adding this to your .vimrc:

set smartindent

It will increase the indent in a new block.

share|improve this answer

Both will annoy you when pasting (as vim will try and indent everything on the fly). So prior to pasting:

:set paste

share|improve this answer
This is true in the terminal. If you're using gvim you shouldn't need this. – Nathan Fellman Jul 28 '14 at 17:25
In complex situations (virtual machines, remote desktops, ...), even gvim will not have access to the clipboard. On the other hand, running vim locally will have access to the clipboard and vim can paste properly if you use "*p or "+p. Sometimes vim and :set paste and 'dumb' pasting-raw-to-the-terminal are the only option. – Aaron McDaid Dec 9 '14 at 13:34

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.