4

I have set autoindent in my .vimrc

Say I'm on an indented line in Vim in insert mode. If I make a bunch of new lines by pressing enter, it'll keep my cursor indented. However, lines between my current line and the original line lose their indents. This doesn't happen with Notepad++

| indicates the indent on the empty lines.

Vim:

function f()
{
    var x;
|
|
|
    |//cursor

Notepad++:

function f()
{
    var x;
    |
    |
    |
    |//cursor

How do I get Vim to behave like Notepad++?

Linny
  • 323
  • 1
  • 2
  • 10
  • Do you really want to have all those trailing white spaces? – romainl Jul 27 '15 at 05:26
  • possible duplicate of [stopping vim from removing indentation on empty lines](http://stackoverflow.com/questions/7413036/stopping-vim-from-removing-indentation-on-empty-lines) – ryuichiro Jul 27 '15 at 06:06

1 Answers1

2

Try this and let me know if it fixes your problem.

** In normal mode **

:set smartindent

** Or in your .vimrc file add this **

set smartindent
  • Nope. I didn't notice any difference. – Linny Jul 26 '15 at 23:55
  • Linny, what version vim are you using? – newbydewbydew Jul 26 '15 at 23:56
  • Interesting...I've got 7.3, tested your scenario, and smartindent worked for me. The only other command that might work is cindent. This guy seems to be having similar issues with that version...http://stackoverflow.com/questions/19323607/html-indenting-not-working-in-compiled-vim-7-4-any-ideas – newbydewbydew Jul 27 '15 at 12:31