如何让 Vim 尊重 .editorconfig?
How do I make Vim respect .editorconfig?
我使用了 Vundle to install editorconfig-vim 插件。它正确加载并列在 :scriptnames
中。但是当我创建一个新文件时,比如 x.js
,缩进设置不是从 ~/.editorconfig
文件中选择的(尽管 CWD 中没有 .editorconfig
),我有 2-space 缩进而不是我在 ~/.editorconfig
.
中定义的 4-space
我做错了什么?我应该在 ~/.vimrc
中调用某个命令来使 EditorConfig 配置工作吗?
我的~/.editorconfig
:
root = true
[*]
end_of_line = lf
insert_final_newline = true
charset = utf-8
indent_style = space
indent_size = 4
[{package.json,.travis.yml,Gruntfile.js,gulpfile.js,webpack.config.js}]
indent_style = space
indent_size = 2
还有我的 ~/.vimrc
配置:
set nocompatible " be iMproved, required
filetype off " required
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
Plugin 'gmarik/Vundle.vim'
Plugin 'tpope/vim-fugitive'
Plugin 'tomasr/molokai'
Plugin 'moll/vim-node'
Plugin 'jelera/vim-javascript-syntax'
Plugin 'pangloss/vim-javascript'
Plugin 'editorconfig/editorconfig-vim'
call vundle#end() " required
filetype plugin indent on " required
" set tw=80
" set wrap linebreak nolist
let g:jsx_ext_required = 0 " Allow JSX in normal JS files
let g:syntastic_javascript_checkers = ['eslint']
let g:EditorConfig_core_mode = 'external_command'
syntax on
set number
set ruler
colorscheme molokai
可能是另一个插件覆盖了 editorconfig 插件。
这件事发生在我身上。我忘记了安装 https://github.com/Raimondi/YAIFA(又一个缩进查找器,差不多)。如果插件功能更容易从其名称中解析,我可能会更快地发现问题。
您可能需要使用 :verbose set tabstop?
检查哪个插件为您设置的。
如果没有说Last set from ...
,则使用默认选项。
然后,editorconfig没有相应的设置,你可能要检查一下.editorconfig
使用的是哪个。
它帮助我 init.lua
设置:
vim.cmd('filetype plugin on')
vim.cmd('filetype indent off')
另外:verbose set autoindent?
给出了实际设置值和加载位置。文件类型设置在全局设置之后加载。禁用文件类型缩进后,我的 editorconfig 开始按照我预期的方式工作。您还可以通过 filetype off
禁用所有文件类型选项
我使用了 Vundle to install editorconfig-vim 插件。它正确加载并列在 :scriptnames
中。但是当我创建一个新文件时,比如 x.js
,缩进设置不是从 ~/.editorconfig
文件中选择的(尽管 CWD 中没有 .editorconfig
),我有 2-space 缩进而不是我在 ~/.editorconfig
.
我做错了什么?我应该在 ~/.vimrc
中调用某个命令来使 EditorConfig 配置工作吗?
我的~/.editorconfig
:
root = true
[*]
end_of_line = lf
insert_final_newline = true
charset = utf-8
indent_style = space
indent_size = 4
[{package.json,.travis.yml,Gruntfile.js,gulpfile.js,webpack.config.js}]
indent_style = space
indent_size = 2
还有我的 ~/.vimrc
配置:
set nocompatible " be iMproved, required
filetype off " required
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
Plugin 'gmarik/Vundle.vim'
Plugin 'tpope/vim-fugitive'
Plugin 'tomasr/molokai'
Plugin 'moll/vim-node'
Plugin 'jelera/vim-javascript-syntax'
Plugin 'pangloss/vim-javascript'
Plugin 'editorconfig/editorconfig-vim'
call vundle#end() " required
filetype plugin indent on " required
" set tw=80
" set wrap linebreak nolist
let g:jsx_ext_required = 0 " Allow JSX in normal JS files
let g:syntastic_javascript_checkers = ['eslint']
let g:EditorConfig_core_mode = 'external_command'
syntax on
set number
set ruler
colorscheme molokai
可能是另一个插件覆盖了 editorconfig 插件。
这件事发生在我身上。我忘记了安装 https://github.com/Raimondi/YAIFA(又一个缩进查找器,差不多)。如果插件功能更容易从其名称中解析,我可能会更快地发现问题。
您可能需要使用 :verbose set tabstop?
检查哪个插件为您设置的。
如果没有说Last set from ...
,则使用默认选项。
然后,editorconfig没有相应的设置,你可能要检查一下.editorconfig
使用的是哪个。
它帮助我 init.lua
设置:
vim.cmd('filetype plugin on')
vim.cmd('filetype indent off')
另外:verbose set autoindent?
给出了实际设置值和加载位置。文件类型设置在全局设置之后加载。禁用文件类型缩进后,我的 editorconfig 开始按照我预期的方式工作。您还可以通过 filetype off