2016-06-16 14 views
1

Ich habe dieses Skript Variablen zu setzen, wenn Python-Dateien LadenVim autocmd Fehler

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

Wenn ich eine Python-Datei laden bekomme ich diesen Fehler:

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

Nur ein Vorschlag: es sieht aus wie das, was Sie wirklich wollen ist das Ereignis 'Dateityp' und nicht' BufNewFile' und 'BufRead'. – lwassink

Antwort

4

Dies sollte funktionieren:

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

oder

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

oder

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

Cool, nur brauchte das Leerzeichen nicht. –

0

Sie können tun. statt * .test und es funktioniert für mich. (Astrix. Astrix)

Beispiel: au BufNewFile, BufRead . Satz tabstop = 4

0

Im Folgenden sind ein paar Möglichkeiten, zu erreichen, was Sie wollen:

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

ODER

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

Explanation :

In your autocommand you're calling the :set (:h :set) command which is used to set vim options. If you want to set multiple options, you can either call :set with multiple options separated with whitespace or call :set multiple times for each option, separating each :set command with the | (:h :bar).

Tip :

Since your objective is to define certain options specifically for python files, you should either use :autocmd Filetype python ... for this, or better yet create a ftplugin/python/custom.vim file where you can enable these settings using the :setlocal command as opposed to :set to set them only for the current buffer.