vim setting error under BufRead


Vim Problem Overview

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


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?

Vim Solutions

Solution 1 - Vim

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

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

Read more :help :bar.

Solution 2 - Vim

please use one set with space separated options:

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


All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionAnthonyCView Question on Stackoverflow
Solution 1 - VimsvlasovView Answer on Stackoverflow
Solution 2 - VimKentView Answer on Stackoverflow