Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

EditorConfig 는 환경(Editor, OS, fIle encoding)에 따라 코딩 스타일의 일관성이 깨지는 문제를 해결하기 위한 표준으로  character encoding, 개행 처리 방법, 들여쓰기 방법(tab인지 space 인지) 등을 정의하고 있으므로 Editorconfig 를 지원하는 에디터를 사용한다면 프로젝트 참여자들의 일관된 코딩 스타일을 유지할 수 있습니다.

설치

사전 설치

에디터나 플랫폼에 따라 editorConfig 기능을 지원하는 경우가 있습니다.

Pre installed 에서 목록을 볼 수 있으며 IntelliJ 나 Visual Studio(Code 말고!), Pycharm 등이 별도 설치없이 editorConfig 를 지원합니다.

Image Added

Plugin 설치

위 목록에 없는 에디터나 IDE 라면 별도로 플러그인을 설치해야 합니다.

download 에서 사용하는 환경에 맞는 플러그인을 설치해 주면 되며 다음은 대표적인 editor 용 plugin 페이지입니다.


사용

프로젝트 root 에 .editorconfig 파일을 만들고 프로젝트 참여자들간의 일관성 유지를 위해 이 파일을 버전 관리에 추가해 주면 됩니다.


대괄호안에 적용할 파일 확장자를 기술해주고 설정 값을 적어줍니다. * 로 할 경우 모든 파일에 대해서 적용합니다.


다음은 모든 파일 인코딩을 UTF-8 을 사용하고 들여쓰기는 space 4칸, 개행은 LF 를 사용하고 yaml 파일에 대해서는 들여쓰기를 2 칸으로 하는 예졔입니다.

Code Block
# top-most EditorConfig file
root = true

# Unix-style newlines with a newline ending every file 
[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
indent_style = space
indent_size = 4
trim_trailing_whitespace = true

[*.{yml,yaml}]
indent_size = 2



Code Block
# EditorConfig is awesome: https://EditorConfig.org

# top-most EditorConfig file
root = true

# Unix-style newlines with a newline ending every file 
[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
indent_style = space
indent_size = 4
trim_trailing_whitespace = true

[*.md]
trim_trailing_whitespace = false

[*.{yml,yaml}]
indent_size = 2

# Matches multiple files with brace expansion notation
# Set default charset
[*.{js,py}]
charset = utf-8

# 4 space indentation
[*.py]
indent_style = space
indent_size = 4

# Tab indentation (no size specified)
[Makefile]
indent_style = tab 

# Matches the exact files either package.json or .travis.yml
[{package.json,.travis.yml}]
indent_style = space
indent_size = 2

...