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

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

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

Arup Rakshit-2
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:


set nocompatible              " required
filetype off                  " required

" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()

" alternatively, pass a path where Vundle should install plugins
"call vundle#begin('~/some/path/here')

" let Vundle manage Vundle, required
Plugin 'gmarik/Vundle.vim'

" add all your plugins here (note older versions of Vundle
" used Bundle instead of Plugin)

" ...

Plugin 'tmhedberg/SimpylFold'

" All of your Plugins must be added before the following line
call vundle#end()            " required

let g:SimpylFold_docstring_preview=1

set splitbelow
set splitright

" Enable folding
set foldmethod=indent
set foldlevel=99

" split navigations
nnoremap <C-J> <C-W><C-J>
nnoremap <C-K> <C-W><C-K>
nnoremap <C-L> <C-W><C-L>
nnoremap <C-H> <C-W><C-H>

" Enable folding with the spacebar
nnoremap <space> za

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

filetype plugin indent on    " required

--
--
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 [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

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

Gary Johnson-4
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 [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

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

Arup Rakshit-2

Thank you Gary. It worked now.



> On 03-Apr-2019, at 10:22 AM, Gary Johnson <[hidden email]> wrote:
>
> 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 [hidden email].
> For more options, visit https://groups.google.com/d/optout.

--
--
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 [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

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

chrisheithoff
Instead of writing your own Python autocmd, have you already been aware of the Vim filetype plugin for Python already does?

See the ftplugin/python.vim script in the Vim runtime path.

--
--
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 [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

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

Gary Johnson-4
On 2019-04-04, chrisheithoff wrote:
> Instead of writing your own Python autocmd, have you already been
> aware of the Vim filetype plugin for Python already does?
>
> See the ftplugin/python.vim script in the Vim runtime path.

Good point.  If you want to add to or modify the settings in that
file, _don't_modify_that_file_.  Any changes you make to that file
may be lost the next time you update Vim.  Instead, put your
settings into an after plugin you create, in this case,
~/.vim/after/ftplugin/python.vim.  Also, for filetype-specific
settings, you should use setlocal rather than set, e.g.,

    setlocal tabstop=4
    setlocal softtabstop=4
    setlocal shiftwidth=4
    setlocal textwidth=79
    setlocal expandtab
    setlocal autoindent
    setlocal fileformat=unix

See:

    :help ftplugin-overrule

The above will work fine, but to do it "right", the after/ftplugin
file should look like this:

    let s:save_cpo = &cpo
    set cpo-=C

    setlocal tabstop=4
    setlocal softtabstop=4
    setlocal shiftwidth=4
    setlocal textwidth=79
    setlocal expandtab
    setlocal autoindent
    setlocal fileformat=unix

    let b:undo_ftplugin = (exists("b:undo_ftplugin") ? b:undo_ftplugin . "|" : "")
        \ . "setlocal tabstop< softtabstop< shiftwidth< textwidth< expandtab< autoindent< fileformat<"

    let &cpo = s:save_cpo
    unlet s:save_cpo

See:

    :help undo_ftplugin
    :help filetype-plugin
    :help use-cpo-save

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 [hidden email].
For more options, visit https://groups.google.com/d/optout.