如何让Vim尊重.editorconfig?

时间:2015-07-08 14:19:21

标签: vim vundle editorconfig

我使用Vundle来安装editorconfig-vim插件。它正确加载并列在:scriptnames中。但是,当我创建一个新文件时,例如,x.js,不会从~/.editorconfig文件中选择缩进设置(尽管CWD中没有.editorconfig),并且我有2个空格缩进而不是我在~/.editorconfig中定义的4空格。

我做错了什么?我应该在~/.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

2 个答案:

答案 0 :(得分:2)

您可能希望使用:verbose set tabstop?来检查为您设置的插件。

如果没有说Last set from ...,则使用默认选项。

然后,editorconfig没有相应的设置,您可能想要检查使用了哪个.editorconfig

答案 1 :(得分:1)

另一个插件可能会覆盖editorconfig插件。

这发生在我身上。我忘记了安装https://github.com/Raimondi/YAIFA(又一个Indent Finnt,几乎)。如果插件功能更容易从其名称解析,我可能会在我的情况下更快地找到问题。