ãžã§ãã¬ãŒã¿äœãã®ç·Žç¿ã§ãEditorConfigã®èšå®ãžã§ãã¬ãŒã¿ãŒãäœããŸããã
ä»åã¯ããã®ã€ãã§ã«æ¥æ¬èªèš³ããããã®ãæ²èŒããŸãð
ãã®åã«ãEditorConfigãšã¯ïŒ
ã³ãŒãã£ã³ã°ãããšãã®åºæ¬ã®1ã€ð
ã€ã³ãã³ãã®çš®é¡ãæ¹è¡ã³ãŒããªã©ãçµ±äžããŠããã倧å€æåãªä»çµã¿ã§ãã
Gitã§äœèšãªå·®åã§çŸãããšé¢åãªäœèšãªç©ºçœããæ¹è¡ã³ãŒãã®éãã解決ããŠãããåªããã®ã§ãã
Visual Studio Codeã¯ãã¡ãããããŸããŸãªãšãã£ã¿ã§åããããšãã§ããŸãã
ãããžã§ã¯ãïŒãã©ã«ãïŒã®äžã«EditorConfigãã¡ã€ã«ïŒ.editorconfig
ïŒãäœãããã¡ã€ã«ã®çš®é¡ããšã«ã«ãŒã«ãèšè¿°ããŠãããŸãã
VS Codeã®å Žåã¯å°çšã®ãšã¯ã¹ãã³ã·ã§ã³ãã€ã³ã¹ããŒã«ãããç¶æ
ã§ãEditorConfigãã¡ã€ã«ãå«ããããžã§ã¯ãã®äžã®ãã¡ã€ã«ãä¿åãããšãEditorConfigã«ãã£ãŠã³ãŒããæŽããããŸãã
EditorConfigã®ä»æ§ïŒæ¥æ¬èªèš³ïŒ
ã¯ããã«ãããã€ããã®æ¥æ¬èªèš³ã§ç»å Žããçšèªã玹ä»ããŸãã
- èšå®ãã¡ã€ã«ïŒEditorConfigã®èšå®ãã¡ã€ã«ã§ãã€ãŸãã¯ã.editorconfigãã®ããš
- ã³ã¢ïŒèšå®ãã¡ã€ã«ã解æããæ©èœã®ããš
- ã»ã¯ã·ã§ã³ãããïŒèšå®ãã¡ã€ã«ã«ãããŠã¯ãglob圢åŒã®ãã¡ã€ã«ãã¹ã®ããš
- ããŒãšå€ã®ãã¢ïŒèšå®ãã¡ã€ã«ã«èšèŒããã«ãŒã«1ã€1ã€ã®ããš
# ããŒãšå€ã®ãã¢
root = true
# ã»ã¯ã·ã§ã³ããã
[*]
# ããŒãšå€ã®ãã¢
indent_size = 2
以äžãåæããããã€ãŸãã æ¥æ¬èªèš³ã§ãã
åæã¯ãã¡ãïŒEditorConfig Specification
File Format - .editorconfig
ã®ãã¡ã€ã«åœ¢åŒ
èšå®ãã¡ã€ã«ã¯INIãã¡ã€ã«ã®ãããªãã©ãŒãããã§èšè¿°ãããŸãã
ãã®èšå®ãã¡ã€ã«ã§ã¯ãåè¡é ã®ç©ºçœæåã¯ç¡èŠãããŸãã
åè¡ã¯ãããã次ã®ããããã§ããå¿ èŠããããŸãã
- 空è¡ïŒç©ºçœæåã®ã¿
-
ã³ã¡ã³ãïŒ
;
ãŸãã¯#
ã§å§ãŸããŸã- è¡å ã§ç©ºçœæå以å€ã®åŸã«ãããã®èšå·ãæ¿å ¥ããŠããã³ã¡ã³ããšããŠè§£éããããã»ã¯ã·ã§ã³åããã¢ïŒåŸè¿°ïŒã®äžéšãšããŠã解éãããŸããããªããããã¯å°æ¥çã«å€æŽãããå¯èœæ§ãããããããããã«ããŠãéæšå¥šã§ãã
-
ã»ã¯ã·ã§ã³ãããïŒ
[
ã§å§ãŸãã]
ã§ããããŸã- ãã®è¡ã§ã¯è§æ¬åŒ§ã®å€åŽã«ç©ºçœæå以å€ãèšè¿°ã§ããŸãã
- è§æ¬åŒ§ã®äžã«ã¯ä»»æã®æåãå
¥ããããšãã§ããŸã
- ãã¹ã®åºåãã«ã¯ã¹ã©ãã·ã¥ãçšããŸãïŒ
/
ïŒ - Windowsã®å Žåã§ããããã¯ã¹ã©ãã·ã¥ããã¹ã®åºåããšããŠäœ¿ãããšã¯ã§ããŸãã
- ãã¹ã®åºåãã«ã¯ã¹ã©ãã·ã¥ãçšããŸãïŒ
-
ããŒãšå€ã®ãã¢ïŒä»¥äžããã¢ïŒïŒ
=
ã§åºåãããããŒãšå€
ãããã«åœãŠã¯ãŸããªãè¡ã¯ç¡èŠãããŸãã
èšå®ãã¡ã€ã«ã¯ãæ¹è¡ã³ãŒãããLFããŸãã¯ãCRLFããæåã³ãŒãããUTF-8ãã§ããå¿ èŠããããŸãã
Glob Expressions - ã»ã¯ã·ã§ã³åã®æžãæ¹
èšå®ãã¡ã€ã«ã®ã»ã¯ã·ã§ã³åã¯ã.gitignore
ã§æå¹ãªãã©ãŒããããšåãglobã䜿ã£ããã¡ã€ã«ãã¹ã§ãã
ããã¯ãUnix shell-styleã®ã¯ã€ã«ãã«ãŒãã«ãããã¿ãŒã³ãããããµããŒãããŠããŸãã
globã§ã¯ã次ã®èšå·ãç¹æ®æåãšããŠèªèããŸãã
èšå· | åœ¹å² |
---|---|
* |
ãã¹ã®åºåãæåïŒ/ ïŒãé€ãä»»æã®æåå |
** |
ä»»æã®æåå |
? |
ãã¹ã®åºåãæåïŒ/ ïŒãé€ãä»»æã®äžæå |
[seq] |
ãseqãã®ãã¡ä»»æã®äžæå |
[!seq] |
ãseqã以å€ã®ä»»æã®äžæå |
{s1,s2,s3} |
ã«ã³ãåºåãã®æååã®ãã¡ããããïŒããã¯å ¥ãåã«ã§ããŸãïŒ |
{num1..num2} |
num1ãnum2ã®éã®ä»»æã®æŽæ°ïŒnum1ãšnum2ã¯è² ã®å€ã§ãOKïŒ |
ç¹æ®æåãšããŠè§£éãããªãããã«ããã«ã¯ãããã¯ã¹ã©ãã·ã¥ïŒ\
ïŒãçšããŠãšã¹ã±ãŒãããŸãã
ã³ã¢ã¯ã1024æåãŸã§ã®ã»ã¯ã·ã§ã³åãåãå
¥ããŸãªããã°ãªããŸããã
åå®è£
ãç¬èªã«äžéãèšå®ããããæ瀺çãªäžéãèšå®ããªãããšãã§ããŸãã
File Processing - èšå®ãã¡ã€ã«ã®èªã¿èŸŒã¿
EditorConfigã¯ãã¡ã€ã«åãæž¡ããããšããã®ãã¡ã€ã«ã®ãã£ã¬ã¯ããªãšãã¹ãŠã®èŠªãã£ã¬ã¯ããªããèšå®ãã¡ã€ã«ïŒããã©ã«ãã§ã¯.editorconfig
ãšããååïŒãæ€çŽ¢ããŸãã
ååšããªããã£ã¬ã¯ããªã¯ãååšãã空ã®ãã£ã¬ã¯ããªãšããŠæ±ãããŸãã
èŠã€ãããããã¹ãŠã®èšå®ãã¡ã€ã«ã¯ãæž¡ããããã¡ã€ã«åã«äžèŽããã»ã¯ã·ã§ã³åããã€ã»ã¯ã·ã§ã³ãæ€çŽ¢ããŸãã
èšå®ãã¡ã€ã«ã®root
ãtrue
ã«èšå®ãããŠããèšå®ãã¡ã€ã«ãŸã§ãã©ãçããå ŽåããŸãã¯ãã¡ã€ã«ã·ã¹ãã ã®ã«ãŒããã£ã¬ã¯ããªãŸã§å°éãããšããæ€çŽ¢ãçµäºããŸãã
èšå®ãã¡ã€ã«ã¯äžäœãã£ã¬ã¯ããªããäžäœãã£ã¬ã¯ããªã®é ã«èªã¿èŸŒãŸããæåŸã«èªã¿èŸŒãŸããã«ãŒã«ãåªå
ãããŸãã
è€æ°ã®èšå®ãã¡ã€ã«ã«ãããããã»ã¯ã·ã§ã³ãããå Žåãããè¿ãèšå®ãã¡ã€ã«ã®ã«ãŒã«ãæåŸã«èªãŸãããããããè¿ããã¡ã€ã«ã®ãã¢ãåªå
ãããŸãã
Supported Pairs - ãµããŒããããŠãããã¢
èšå®ãã¡ã€ã«ã®ã»ã¯ã·ã§ã³ã¯ãã€ã³ãŒã«ïŒ=
ïŒã§åºåãããããŒãšå€ã®ãã¢ã§æ§æãããŠããŸãã
root
ãé€ããŠããã¹ãŠã®ãã¢ã¯ã»ã¯ã·ã§ã³ãããããåŸã®è¡ã«èšè¿°ããªããã°ãªããŸããã
EditorConfigã®ãã©ã°ã€ã³ã¯ãèªèãããŠããªãããŒãç¡å¹ãªãã®ããµããŒããããŠããªãããŒã®å€ãç¡èŠããªããã°ãªããŸããã
ãã®ä»æ§ã®ãã®ããŒãžã§ã³ã§å®çŸ©ãããŠãããã¹ãŠã®ããŒãšããããã«é¢é£ãããµããŒããããŠããå€ã®ãªã¹ãã¯ã次ã®éãã
ïŒäŸ¿å®äžãäžéšæ¬¡ã®ãããªç¬èªã®è¡šçŸãçšããŸãïŒ
-
number
- åè§æ°åãæããŸã -
boolean
-true
ãŸãã¯false
ã®ãããããæããŸã
ããŒå | èšå®å¯èœãªå€ | ãåè |
---|---|---|
indent_style |
"space" "tab"
|
ã€ã³ãã³ãã«ãã¹ããŒã¹ããã¿ããã©ã¡ãã䜿ãã決ããŸãã ãªããå€ã¯å€§æåå°æåãèæ ®ããŸããã |
indent_size |
number "tab"
|
ã€ã³ãã³ãã®ç©ºçœæåæ°ã決å®ããŸãã ãã®å€ã tab ã®å Žåãtab_width ã®å€ãå©çšãããŸãããªããå€ã¯å€§æåå°æåãèæ ®ããŸããã |
tab_width |
number |
ã¿ãæåã®å¹
ã決ããŸãã ããã©ã«ã㯠indent_size ã®å€ãå©çšããããããéåžžã¯æå®ããå¿
èŠã¯ãããŸããã |
end_of_line |
"lf" "cr" "crlf"
|
æ¹è¡ã³ãŒãã決å®ããŸãã ãªããå€ã¯å€§æåå°æåãèæ ®ããŸããã |
charset |
"latin1" "utf-8" "utf-8-bom" "utf-16be" "utf-16le"
|
æåã³ãŒãã決å®ããŸããutf-8-bom ã¯éæšå¥šã§ãã |
trim_trailing_whitespace |
boolean |
true ãèšå®ãããšããã¡ã€ã«ã®ä¿åæã«è¡æ«ïŒæ¹è¡æåããåïŒã®ç©ºçœæåãåé€ããŸãã |
insert_final_newline |
boolean |
true ãèšå®ãããšããã¡ã€ã«ã®ä¿åæã«æ«å°Ÿã«1ã€ã®ç©ºè¡ãè¿œå ãããŸãã |
root |
boolean |
true ãèšå®ãããšããã®èšå®ãã¡ã€ã«ãããäžäœãã£ã¬ã¯ããªãæ€çŽ¢ããªããªããŸãããªããèšå®ãã¡ã€ã«ã®å é ã«èšè¿°ããå¿ èŠããããŸãã |
ãããã®ãã¢ããå€ã«unset
ãèšå®ããããšãã§ããŸãããã®å€ã¯ããã®ããŒããã§ã«èšå®æžã¿ã ã£ããšããŠãããããç¡å¹ã«ããŸãã
ããšãã°ãindent_size = unset
ãè¿œå ãããšãindent_size
ã®å®çŸ©ãç¡å¹ã«ãªããŸãïŒãšãã£ã¿ã®ããã©ã«ãèšå®ãåç
§ãããïŒã
ãã¢ã®ããŒã¯ã倧æåãšå°æåãåºå¥ããã解æåŸã«ãã¹ãŠå°æåã«ãªããŸãã
ã³ã¢ã¯ã1024ã4096æåãŸã§ã®é·ãã®ããŒãšå€ãåãå
¥ããŸãªããã°ãªããŸããã
åå®è£
ãç¬èªã«äžéãèšå®ããããæ瀺çãªäžéãèšå®ããªãããšãã§ããŸãã
Suggestions for Plugin Developers - ãã©ã°ã€ã³éçºè ãžã®ææ¡
æºåäžããšãããããGitHub wikiã®Plugin Guidelinesãèªãã§ãã ããã
äžéšå²æããŠããéšåããããŸããããã¡ãã§ä»¥äžã§ãã
ããŸãŸã§ãã£ãšäœ¿ã£ãŠããã®ã«ãindent_size
ã«tab
ãªããŠå€ãèšå®ã§ãããªããŠç¥ããŸããã§ããð
æåŸã«ããããèšå®
å人çãªããããèšå®ã¯ãã¡ã( ËÏË )
ææ°çã¯ãã¡ãïŒhttps://gist.github.com/heppokofrontend/1587734087a9476dfe3fc16fb770bb96
root = true
[*]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
[*.{md,mdx}]
trim_trailing_whitespace = false
[*.ps1]
charset = utf-8-bom
# FOR WINDOWS
[*.{cmd,bat}]
end_of_line = crlf
åºæ¬çã«ã¯LFã®ã€ã³ãã³ã2ãäœèšãªç©ºçœç¡ãããã ãMarkdownã§ã¯è¡æ«ã®ã¹ããŒã¹ã¯æ¹è¡ãè¡šãã®ã§ãããªãã³ã°ãããªãããã«false
ãæå®ããŠããŸãã
PowerShellçšã®ãã¡ã€ã«ã¯BOMã€ãUTF-8ã§ãªããã°ãªããªãããæå®ããŠããŠãWindowsåãã®ããããã¡ã€ã«ã¯CRLFã§ãªããã°ãªããªãããæå®ããŠããŸãã
éçšãé·ããªãããšãäºæ³ãããããããŸããŸãªç°å¢ã®éçºè ãåç»ããããšãäºèŠãããç¶æ³ã§ã®éçºç°å¢æ§ç¯ã§ã¯ãããããããããå°ããïŒïŒããšããããšãèµ·ãããªãããã«èšå®ãæžããŠãããšãããšæã£ãŠããŸãã
ããã³ãŒãã£ã³ã°ã©ã€ãããïŒïŒ