45

I've got a line in my .vimrc that is more than 80 chars long:

autocmd FileType python set smartindent cinwords=if,elif,else,for,while,try,except,finally,def,class,with

I find this rather annoying, so I want to break it into multiple lines, but I don't know how to do that. I tried \ since that does the trick in Python and the Bourne shell, but apparently that's not valid syntax in Vim:

autocmd FileType python set smartindent \
    cinwords=if,elif,else,for,while,try,except,finally,def,class,with

gives

E492: Not an editor command

Can anyone tell me how to split this line?

(Bonus points if someone can tell me how to add to cinwords instead of resetting it entirely; the only thing I wanted to achieve is add the with keyword to it.)

Todd A. Jacobs
  • 81,402
  • 15
  • 141
  • 199
Fred Foo
  • 355,277
  • 75
  • 744
  • 836
  • Close duplicate of http://stackoverflow.com/questions/8006117/wrap-long-lines-in-vimrc. – Todd A. Jacobs May 31 '12 at 10:25
  • @CodeGnome: didn't search for line wrapping because I thought that meant something else, but you're right. – Fred Foo May 31 '12 at 10:36
  • 1
    If you are doing some filetype-specific things you should be using `:setlocal`, not `:set`. The command you posted adds `with` to the 'cinwords' and sets 'smartindent' in every subsequent buffer, not only python, unless this buffer filetype plugin overrides it. – ZyX May 31 '12 at 18:02

2 Answers2

64

Hit :help line-continuation.

Basically you have to add \ at the beginning of the continued line.

So instead of writing

autocmd FileType python set smartindent \
    cinwords=if,elif,else,for,while,try,except,finally,def,class,with

you have to write

autocmd FileType python set smartindent
       \ cinwords=if,elif,else,for,while,try,except,finally,def,class,with
shime
  • 8,746
  • 1
  • 30
  • 51
48
autocmd FileType python set smartindent
    \ cinwords+=with
Todd A. Jacobs
  • 81,402
  • 15
  • 141
  • 199