EditorConfig this configuration file and a set of extensions to a lot of code editors and IDE (Then just IDE).
[Editor Config]
Its mission - to create a single format settings, and once and for all, solve questions like "tabs or spaces" for all IDE and programming languages.
Files. Editorconfig can be found in projects such as jQuery, Ruby, WordPress, and many others.
Plugins are available for a large number of IDE
Let's see how it works.File looks like EditorConfig?Here is an example . Editorconfig, which sets the indentation rules for Python and JavaScript code :# # Apologize in advance for the lack of proper syntax highlighting in this example further.# # Although the "ini" and included in the list of formats supported Habré , the code does not become beautiful .# # If anyone knows how to fix it - please write to the PM.## Root file EditorConfigroot = true# For all files using unix- compatible line breaks[*]end_of_line = lfinsert_final_newline = true# 4 space indentation[*. py]indent_style = spaceindent_size = 4# Use tabs for indentation (do not specify size)[*. js]indent_style = tab# Perezavisyvaem indent for js files in the lib[lib / **. js]indent_style = spaceindent_size = 2# Files only package.json or. Travis.yml[{package.json,. travis.yml}]indent_style = spaceindent_size = 2file FormatEditorConfig files use slightly modified INI format .Each . Editorconfig must be in UTF- 8 , and at the end of lines must be eitherCRLF or LF.As the section name appears mask files, such as [*. Js] or [index.html].Unlike conventional . Ini format in the section name can be used [ and ] that allows you to specify a list of characters , one of which must be in the position specifications . For example, such constructions like this : [file [ 123 ]. Js]. How it works - see below .Each comment must be on a separate line and begin with ; or # .How does the file search mask* - Any number of characters except a path separator ( / )Example : [*. Js]hello.js / / Matchhellojs / / No matchindex.html / / No matchlib / source.js / / No match** - Any number of charactersExample : [**. Js]hello.js / / Matchhellojs / / No matchindex.html / / No matchlib / source.js / / Match? - Any single characterExample : [hell?. Js]hello.js / / Matchhell.js / / No match[name] - Any character of the symbols contained in the "name"Example : [[abc]. Js]a.js / / Matchb.js / / Matchabc.js / / No match[! name] - Any character that is not present in the "name"Example : [file [! 2468 ]. Js]file1.js / / Matchfile2.js / / No match{s1, s2, s3} - Any of the strings separated by commasExample : [index. {Js, html}]index.js / / Matchindex.html / / Matchpackage.json / / No match\ - Escaping special charactersExample : [\ [abc \]. Js]a.js / / No match<b> [abc] </ b>. js / / MatchsettingsThat can be configured ?Editor config tends to be independent of language and work in all IDE. Unfortunately this is not always possible, so some of the plug-ins do not support all settings. More information can be found on the page of each plug-in githabe .All settings are case-insensitive .indent_styleValues : tab, spaceAllows you to set a hard or soft tabs for indentation .indent_sizeValues: NumberDefines the width of indentation using soft tabs.tab_widthValues: NumberDefines the width of indentation using rigid tab . If not specified, will take the value of indent_size.end_of_lineValues : lf, cr, crlfAllows you to choose what to use at the ends of lines.charsetValues : latin1, utf- 8 , utf- 8 -bom, utf-16be, utf-16leAllows you to select the encoding for the file .Use utf- 8 -bom not recommendedtrim_trailing_whitespaceValues : true, falseAllows you to remove spaces from the ends of lines .insert_final_newlineValues : true, falseEnsures that at the end of the file will always be a new line.rootValues : true, falseSpecial setting , which should be at the top of the config . If set to true, the parser will not look for other configs parent folders ( details below).Ignore special meaningSome files, such as third-party libraries or minifitsirovannye files , it is better not to touch. In such cases, any setting can be set to ignore. For example:# Specify the formatting for JS and CSS[*. {js, css}]indent_style = spaceindent_size = 2# But not reformat minifitsirovannye JS and CSS files .[*. min. *]indent_style = ignoretrim_trailing_whitespace = falseinsert_final_newline = ignoreAnd why are so few options ?Initial task EditorConfig - create a minimal set of properties that would work in all major IDE.Not an easy task , for example, consider the possibility of adding to that would be limited to the width of the line : max_line_lengthTo add this setting , you need to solve the following questions:
Make sure that all the editors / IDE support it
Decide whether to use hard or soft ( when the line is long physically , but it looks like two ) transfer , or allow the user to select it , adding another setting ( not all editors / IDE support both types of transport )
If you use a hard shift, what to do with languages where rigid transfer can break the code ? (eg HAML)Currently max_line_length property exists, but only works in vim.Expanding EditorConfigOr if a program that uses EditorConfig, encounters an unfamiliar setting, it should ignore it . It allows you to format extensible and is not limited by standard settings.There are two areas for development :Settings for individual editors / IDESome editors / IDE have their own characteristics , such as jEdit set encodings more, so there is setting jedit_charset, which only works for jedit.Settings for individual languages / extensionsThird-party programs and plug-ins can extend EditorConfig and add settings that will work only for certain languages or file extensions.For example npm module CodePainter, which uses EditorConfig as a configuration file , you can select quotes (single or double ) , which will be used for strings (qoute_type), or arrange spaces inside the brackets (spaces_in_brackets). But all this will only work for JavaScript.Just the developers have plans to a range of possible options that may be used in the future, such as :curly_bracket_next_lineSpecifies the transport brace on the next line , for languages where it isjava_class_pathCan be used by other plug-inslanguageAllows you to set the language of the file extension . This can help when templating example Jinja2, using files with the extension . HtmlA full list can be found here (eng.)Where are these files?When the plug-in will need to calculate the configuration file , it will up the file tree from the directory to the root of the file , and load settings from each . Editorconfig file path.Priority setting in the configuration closer to the file above.For a file with this way : / Users / username / code / project / main.js, the plugin will search for the file . Editorconfig sledyuschih places :/ Users / username / code / project / .editorconfig/ Users / username / code / .editorconfig/ Users / username / .editorconfig/ Users / .editorconfig/. editorconfigSearch can be stopped by setting the root = true in one of the config path.This structure allows , for example, create a . Editorconfig in the user folder, and thus get the default settings for all projects , and, if necessary , rewrite these settings a few levels higher .How are the settings within the file ?When the parser reads the file . Editorconfig, it gives higher priority settings that are below .The authors have created a small demo where you can play around with the format and see the resultsFormatting existing codePlugins EditorConfig designed so that they change the settings depending on the IDE file PTFE coating . Sometimes you have to use nedokumentrirovanne or unusual features IDE. Because of this formatting applies only when saving files , and if you want to use EditorConfig with existing code , will have to use one of the tools below.editorconfig-tools [github]Set of tools for testing and reformatting code. Is at an early stage of development and is not very stable.ECLint [github]Is similar in functionality to editorconfig-tools, but , in addition , is able to analyze existing code and generate . Editorconfig file. Also under development.CodePainter [github, npm]Uses . Editorconfig, but only works with JavaScript code.Has special settings for JS code.Plug-ins , how they work and how to create them ?To help the creators of plugins created a set of basic components ( cores) , which can be used in plug-ins and take over the job of finding and parsingukonfiguratsionnyh files. At the moment, there are versions for C, Java, Python, is working nadJavaScript version.Plugins themselves trying to overwrite settings IDE instead engage formatting itself .Unfortunately, there is still no such plugins for IDE like Eclipse or NetBeans, architecture does not allow them to easily change settings.If there is someone among the readers , ready to take on the creation of plug-ins , well here it is painted, how to start (eng.)For Windows usersTo create a file . Editorconfig in Windows Explorer, you need to create a file named . Editorconfig. Windows Explorer and rename it in <code>. editorconfig.References and both can participate inEditorConfig team has done a great job , but there are still many difficulties , interesting problems and solutions :
Writing and plugin support for lesser-known IDE.
Development nuclei for plugins in other languages and the current revision
Increased functionality and add new settings
Refinement of existing solutions to transform codeIf any of the readers would be interested to participate in the project , here are good ways to contact the developers (all in English ) :
Google Groups.
Wiki
bugtracker
Just created an IRC channel EditorConfig on FreeNode, but it is half empty.
[Editor Config]
Its mission - to create a single format settings, and once and for all, solve questions like "tabs or spaces" for all IDE and programming languages.
Files. Editorconfig can be found in projects such as jQuery, Ruby, WordPress, and many others.
Plugins are available for a large number of IDE
Let's see how it works.File looks like EditorConfig?Here is an example . Editorconfig, which sets the indentation rules for Python and JavaScript code :# # Apologize in advance for the lack of proper syntax highlighting in this example further.# # Although the "ini" and included in the list of formats supported Habré , the code does not become beautiful .# # If anyone knows how to fix it - please write to the PM.## Root file EditorConfigroot = true# For all files using unix- compatible line breaks[*]end_of_line = lfinsert_final_newline = true# 4 space indentation[*. py]indent_style = spaceindent_size = 4# Use tabs for indentation (do not specify size)[*. js]indent_style = tab# Perezavisyvaem indent for js files in the lib[lib / **. js]indent_style = spaceindent_size = 2# Files only package.json or. Travis.yml[{package.json,. travis.yml}]indent_style = spaceindent_size = 2file FormatEditorConfig files use slightly modified INI format .Each . Editorconfig must be in UTF- 8 , and at the end of lines must be eitherCRLF or LF.As the section name appears mask files, such as [*. Js] or [index.html].Unlike conventional . Ini format in the section name can be used [ and ] that allows you to specify a list of characters , one of which must be in the position specifications . For example, such constructions like this : [file [ 123 ]. Js]. How it works - see below .Each comment must be on a separate line and begin with ; or # .How does the file search mask* - Any number of characters except a path separator ( / )Example : [*. Js]hello.js / / Matchhellojs / / No matchindex.html / / No matchlib / source.js / / No match** - Any number of charactersExample : [**. Js]hello.js / / Matchhellojs / / No matchindex.html / / No matchlib / source.js / / Match? - Any single characterExample : [hell?. Js]hello.js / / Matchhell.js / / No match[name] - Any character of the symbols contained in the "name"Example : [[abc]. Js]a.js / / Matchb.js / / Matchabc.js / / No match[! name] - Any character that is not present in the "name"Example : [file [! 2468 ]. Js]file1.js / / Matchfile2.js / / No match{s1, s2, s3} - Any of the strings separated by commasExample : [index. {Js, html}]index.js / / Matchindex.html / / Matchpackage.json / / No match\ - Escaping special charactersExample : [\ [abc \]. Js]a.js / / No match<b> [abc] </ b>. js / / MatchsettingsThat can be configured ?Editor config tends to be independent of language and work in all IDE. Unfortunately this is not always possible, so some of the plug-ins do not support all settings. More information can be found on the page of each plug-in githabe .All settings are case-insensitive .indent_styleValues : tab, spaceAllows you to set a hard or soft tabs for indentation .indent_sizeValues: NumberDefines the width of indentation using soft tabs.tab_widthValues: NumberDefines the width of indentation using rigid tab . If not specified, will take the value of indent_size.end_of_lineValues : lf, cr, crlfAllows you to choose what to use at the ends of lines.charsetValues : latin1, utf- 8 , utf- 8 -bom, utf-16be, utf-16leAllows you to select the encoding for the file .Use utf- 8 -bom not recommendedtrim_trailing_whitespaceValues : true, falseAllows you to remove spaces from the ends of lines .insert_final_newlineValues : true, falseEnsures that at the end of the file will always be a new line.rootValues : true, falseSpecial setting , which should be at the top of the config . If set to true, the parser will not look for other configs parent folders ( details below).Ignore special meaningSome files, such as third-party libraries or minifitsirovannye files , it is better not to touch. In such cases, any setting can be set to ignore. For example:# Specify the formatting for JS and CSS[*. {js, css}]indent_style = spaceindent_size = 2# But not reformat minifitsirovannye JS and CSS files .[*. min. *]indent_style = ignoretrim_trailing_whitespace = falseinsert_final_newline = ignoreAnd why are so few options ?Initial task EditorConfig - create a minimal set of properties that would work in all major IDE.Not an easy task , for example, consider the possibility of adding to that would be limited to the width of the line : max_line_lengthTo add this setting , you need to solve the following questions:
Make sure that all the editors / IDE support it
Decide whether to use hard or soft ( when the line is long physically , but it looks like two ) transfer , or allow the user to select it , adding another setting ( not all editors / IDE support both types of transport )
If you use a hard shift, what to do with languages where rigid transfer can break the code ? (eg HAML)Currently max_line_length property exists, but only works in vim.Expanding EditorConfigOr if a program that uses EditorConfig, encounters an unfamiliar setting, it should ignore it . It allows you to format extensible and is not limited by standard settings.There are two areas for development :Settings for individual editors / IDESome editors / IDE have their own characteristics , such as jEdit set encodings more, so there is setting jedit_charset, which only works for jedit.Settings for individual languages / extensionsThird-party programs and plug-ins can extend EditorConfig and add settings that will work only for certain languages or file extensions.For example npm module CodePainter, which uses EditorConfig as a configuration file , you can select quotes (single or double ) , which will be used for strings (qoute_type), or arrange spaces inside the brackets (spaces_in_brackets). But all this will only work for JavaScript.Just the developers have plans to a range of possible options that may be used in the future, such as :curly_bracket_next_lineSpecifies the transport brace on the next line , for languages where it isjava_class_pathCan be used by other plug-inslanguageAllows you to set the language of the file extension . This can help when templating example Jinja2, using files with the extension . HtmlA full list can be found here (eng.)Where are these files?When the plug-in will need to calculate the configuration file , it will up the file tree from the directory to the root of the file , and load settings from each . Editorconfig file path.Priority setting in the configuration closer to the file above.For a file with this way : / Users / username / code / project / main.js, the plugin will search for the file . Editorconfig sledyuschih places :/ Users / username / code / project / .editorconfig/ Users / username / code / .editorconfig/ Users / username / .editorconfig/ Users / .editorconfig/. editorconfigSearch can be stopped by setting the root = true in one of the config path.This structure allows , for example, create a . Editorconfig in the user folder, and thus get the default settings for all projects , and, if necessary , rewrite these settings a few levels higher .How are the settings within the file ?When the parser reads the file . Editorconfig, it gives higher priority settings that are below .The authors have created a small demo where you can play around with the format and see the resultsFormatting existing codePlugins EditorConfig designed so that they change the settings depending on the IDE file PTFE coating . Sometimes you have to use nedokumentrirovanne or unusual features IDE. Because of this formatting applies only when saving files , and if you want to use EditorConfig with existing code , will have to use one of the tools below.editorconfig-tools [github]Set of tools for testing and reformatting code. Is at an early stage of development and is not very stable.ECLint [github]Is similar in functionality to editorconfig-tools, but , in addition , is able to analyze existing code and generate . Editorconfig file. Also under development.CodePainter [github, npm]Uses . Editorconfig, but only works with JavaScript code.Has special settings for JS code.Plug-ins , how they work and how to create them ?To help the creators of plugins created a set of basic components ( cores) , which can be used in plug-ins and take over the job of finding and parsingukonfiguratsionnyh files. At the moment, there are versions for C, Java, Python, is working nadJavaScript version.Plugins themselves trying to overwrite settings IDE instead engage formatting itself .Unfortunately, there is still no such plugins for IDE like Eclipse or NetBeans, architecture does not allow them to easily change settings.If there is someone among the readers , ready to take on the creation of plug-ins , well here it is painted, how to start (eng.)For Windows usersTo create a file . Editorconfig in Windows Explorer, you need to create a file named . Editorconfig. Windows Explorer and rename it in <code>. editorconfig.References and both can participate inEditorConfig team has done a great job , but there are still many difficulties , interesting problems and solutions :
Writing and plugin support for lesser-known IDE.
Development nuclei for plugins in other languages and the current revision
Increased functionality and add new settings
Refinement of existing solutions to transform codeIf any of the readers would be interested to participate in the project , here are good ways to contact the developers (all in English ) :
Google Groups.
Wiki
bugtracker
Just created an IRC channel EditorConfig on FreeNode, but it is half empty.
No comments:
Post a Comment