vim setting error under BufRead
Asked Answered
vim
A

2

70

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?

Abdominal answered 20/4, 2016 at 10:48 Comment(3)
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.Abdominal
| 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.Maharaja
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 autoindentAbdominal
M
167

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

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

Read more :help :bar.

Maharaja answered 20/4, 2016 at 11:51 Comment(1)
Thank you so much!Fleshpots
L
17

please use one set with space separated options:

au BufRead *.py set softtabstop=4 shiftwidth=4
Longspur answered 20/4, 2016 at 11:17 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.