71

Running into a strange issue with my vimrc setting where I isolated to these 2 combination of lines if I use BufRead.

e.g.

au BufRead *.py
    \ set softtabstop=4
    \ set shiftwidth=4

Now if I open a file with .py, I get error:

Error detected while processing BufRead Auto commands for "*.py":
E518: Unknown option: set

This only happens under au BufRead and individually each setting works but not in combination?

AnthonyC
  • 1,880
  • 2
  • 20
  • 27
  • Interesting with | that it works but in my actual file I also had other set option that didn't use | before and they worked fine. So that's strange. – AnthonyC Apr 20 '16 at 13:11
  • `|` is needed when you have multiple commands, `set` in this case. That's why `|` is not needed right after `au BufRead *.py` part. Read more `:help :bar`. – svlasov Apr 20 '16 at 17:37
  • What I meant is that this worked w/ no error: e.g. `au BufNewFile,BufRead *.py` `\ set shiftwidth=4` `\ set textwidth=79` `\ set expandtab` `\ set autoindent` – AnthonyC Apr 21 '16 at 03:34

2 Answers2

167

If you want to use multiple set, separate with |:

au BufRead *.py
    \ set softtabstop=4 |
    \ set shiftwidth=4

Read more :help :bar.

svlasov
  • 9,923
  • 2
  • 38
  • 39
17

please use one set with space separated options:

au BufRead *.py set softtabstop=4 shiftwidth=4
Kent
  • 189,393
  • 32
  • 233
  • 301