Tuesday, April 2, 2019

Re: Error detected while processing BufRead Auto commands for "*.py":

On 2019-04-03, 'Arup Rakshit' via vim_use wrote:
> I am just starting out Vim. I am now making my ~/.vimrc file. But
> I get error after adding the python specific configuration. The
> error is:
>
> Error detected while processing BufRead Auto commands for "*.py":
> E518: Unknown option: set
>
> Here is my ~/.vimrc file:

...

> au BufNewFile,BufRead *.py
> \ set tabstop=4
> \ set softtabstop=4
> \ set shiftwidth=4
> \ set textwidth=79
> \ set expandtab
> \ set autoindent
> \ set fileformat=unix

That error is because Vim does not see all those set commands as
being on separate lines--it sees them as on one line. The
line-continuation operator \ joins its line with the one before it
as though it and the newline terminating the previous line were not
there.

Vim sees your autocommand as this one line:

au BufNewFile,BufRead *.py set tabstop=4 set softtabstop=4 set shiftwidth=4 set textwidth=79 set expandtab set autoindent set fileformat=unix

It interprets the second "set" as another argument to the first
"set", i.e., as an option, but there is no 'set' option, so Vim
issues the error message:

E518: Unknown option: set

One way to fix the problem is to remove all those extra sets, making
your autocommand look like this.

au BufNewFile,BufRead *.py
\ set tabstop=4
\ softtabstop=4
\ shiftwidth=4
\ textwidth=79
\ expandtab
\ autoindent
\ fileformat=unix

Another way is to make each of those set commands a separate command
by separating them with bars, like this.

au BufNewFile,BufRead *.py
\ set tabstop=4
\ | set softtabstop=4
\ | set shiftwidth=4
\ | set textwidth=79
\ | set expandtab
\ | set autoindent
\ | set fileformat=unix

See:

:help line-continuation
:help :bar

Regards,
Gary

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment