Vim autocmd错误
我用这个脚本在加载Python文件时设置变量Vim autocmd错误,vim,Vim,我用这个脚本在加载Python文件时设置变量 au BufNewFile,BufRead *.py \ set tabstop=4 \ set softtabstop=4 \ set shiftwidth=4 \ set textwidth=79 \ set expandtab \ set autoindent \ set fileformat=unix 加载Python文件时,出现以下错误: Error detected while p
au BufNewFile,BufRead *.py
\ set tabstop=4
\ set softtabstop=4
\ set shiftwidth=4
\ set textwidth=79
\ set expandtab
\ set autoindent
\ set fileformat=unix
加载Python文件时,出现以下错误:
Error detected while processing BufRead Auto commands for "*.py":
E518: Unknown option: set
这应该起作用:
au BufNewFile,BufRead *.test set tabstop=4
\softtabstop=4
\shiftwidth=4
\textwidth=790
\expandtab
\autoindent
\fileformat=unix
或
或
你能行。而不是*.test,它对我有效。
(Astrix.Astrix)
例如:
布夫奈维尔,布弗雷德。设置tabstop=4以下是实现所需功能的几种方法:
au BufNewFile,BufRead *.py
\ set tabstop=4 |
\ set softtabstop=4 |
\ set shiftwidth=4 |
\ set textwidth=79 |
\ set expandtab |
\ set autoindent |
\ set fileformat=unix
或
说明:
在自动命令中,您正在调用:set
(:h:set)命令,该命令
用于设置vim选项。如果要设置多个选项,请
可以调用:使用多个用空格分隔的选项设置
或者为每个选项多次调用:set
,将每个:set
带有|
(:h:bar)的命令
提示:
因为您的目标是定义特定于
python文件,您应该使用:autocmd Filetype python…
来
这将创建一个ftplugin/python/custom.vim
文件,其中
您可以使用相反的:setlocal
命令启用这些设置
to:set
仅为当前缓冲区设置它们
很酷,只是不需要空白。只是一个建议:看起来你真正想要的是Filetype
事件,而不是BufNewFile
和BufRead
。
au BufNewFile,BufRead *.test set tabstop=4 softtabstop=4 shiftwidth=4 textwidth=79 expandtab autoindent fileformat=unix
au BufNewFile,BufRead *.py
\ set tabstop=4 |
\ set softtabstop=4 |
\ set shiftwidth=4 |
\ set textwidth=79 |
\ set expandtab |
\ set autoindent |
\ set fileformat=unix
au BufNewFile,BufRead *.py
\ set tabstop=4
\ softtabstop=4
\ shiftwidth=4
\ textwidth=79
\ expandtab
\ autoindent
\ fileformat=unix