You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
EditorConfig makes it easy to maintain the correct coding style when switching between different text editors and between different projects. The EditorConfig project maintains a file format and plugins for various text editors which allow this file format to be read and used by those editors. For information on the file format and supported text editors, see the EditorConfig website.
An flattened config can be loaded from the file system with:
filename="~/Project/foo/lib/foo.rb"config=EditorConfig.load_file(filename)# config: hash of properties and values{"charset"=>"utf-8","indent_style"=>"space","end_of_line"=>"lf","insert_final_newline"=>"carview.php?tsp=true"}
This API walks up the directory hierarchy gathering all .editorconfig files until it reaches a config that defines root = true.
Custom Loader
A custom loader can be provided to read files from another source rather than the file system.
For an example, you might load files directly from a git repository.
A low-level API for parsing an individual .editorconfig file.
A [config, root] tuple is returned. The root bit is set if a top-level root = true is seen. The config value is a two dimensional hash mapping section names to property names and values.
data=File.read(".editorconfig")config,root=EditorConfig.parse(data)# root: if top-most root = true flag is settrue# config: hash of sections and properties{"*"=>{"end_of_line"=>"lf","insert_final_newline"=>"carview.php?tsp=true"},"*.{js,py}"=>{"charset"=>"utf-8"}}
Testing
Cmake is required to run the test suite. On OSX, just brew install cmake.