I really can't find the answer to this and I would like to understand what going on behind the scenes to make this happen. Is it a setting I have switched on? If so, which one?

To give an example, I needed to create a file containing several lines of just spaces, but each time I pressed enter at the end of the line, instead of the cursor going to the beginning of the next line, it just went down directly under its current position.

This wasn't a vim task, I'm just trying to use the editor as much as possible for practice .

  • 2
    Are you in insert mode? If not, vim shows the described behaviour – daniel kullmann May 18 '14 at 21:56
  • 1
    »vi is not an editor« — »What is it then?« — »I think it makes music. All I seem to get from it is beeps.« ;) – Andreas Wiese May 18 '14 at 23:28

It seems that you have smartindent or autoindent enable in your .vimrc file. You can turn off it for current session by typing:

:set nosmartindent
:set noautoindent

in command mode, or make it persistent in your .vimrc file:

set nosmartindent
set noautoindent

You can also just remove set smartindent or set autoindent line in .vimrc to turn smartindent or autoindent off because vim by default has turned off them:

'smartindent' 'si'      boolean (default off)
                        local to buffer
                        {not in Vi}
                        {not available when compiled without the
                        +smartindent feature}
'autoindent' 'ai'       boolean (default off)
                        local to buffer
  • Could also be autoindent – Bernhard May 19 '14 at 6:37
  • @Bernhard: No, if you turn off autoindent but turn on smartindent, the OP's problem still occurs. – cuonglm May 19 '14 at 6:39
  • I mean that if you only have a set autoindent in .vimrc, then you encounter the same problem. He should not look for only smartindent in the .vimrc. I am not trying to claim that your answer is wrong. – Bernhard May 19 '14 at 6:48
  • 1
    @Bernhard: Ah, yes of course. My mistake when thinking that only one option is used. I will update my answer. – cuonglm May 19 '14 at 6:54
  • Thanks. I'm a she by the way :) I do have auto indent set in vimrc. Well, there was an easy explanation. Thanks guys, I wouldn't have thought of it though on my own (at least not for some time), as I'm still getting the hang of it. Much appreciated! – user65751 May 20 '14 at 11:22

Your Answer

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

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