How to add a new line with the same indentation
Then I press Enter in Insert mode, a new line is created, but the cursor is placed at the beginning of the line.
How do I create a new line with the same indentation as the current one?
Solution 1:
Adding set autoindent
to your ~/.vimrc can do that for you automagically.
Solution 2:
I'd also suggest adding this to your .vimrc:
set smartindent
It will increase the indent in a new block.
Solution 3:
Both will annoy you when pasting, as Vim will try and indent everything on the fly.
Prior to pasting enter:
:set paste