[MAC] [IntelliJ] Google style guide format 적용하기
java Google style guide 가 무엇인가?
2022.07.08 - [IT/JAVA | Spring] - [JAVA] Google Java Style Guide link
[JAVA] Google Java Style Guide link
클린코드를 공부하던 중 google java style guide 를 아주 잘 번역되어있는 블로그를 발견했다. 이 블로그는 해당 블로그를 작성하신 작성자분께 허락을 구하고 링크만 남겨놓는다. Google Java Style Guide
kangyb.tistory.com
IDE(intellij, eclipse 등)은 code format을 적용할 수 있다.
그 중 java 개발할 때 많이 참고하는 google java format 을 적용해보자
1. google style guide 파일 다운로드
https://github.com/google/styleguide
GitHub - google/styleguide: Style guides for Google-originated open-source projects
Style guides for Google-originated open-source projects - GitHub - google/styleguide: Style guides for Google-originated open-source projects
github.com
2. intellij 실행 후 preferences 들어가기
상단 바 -> intellij IDEA -> Preferences
또는
command + ,
3. code format 검색 또는 editor -> Code Style 접근
4. 다운받은 파일 적용
Scheme -> 우측 점3개 클릭 -> import Scheme -> Intellij IDEA code style XML 클릭
다운받은 zip파일을 풀면 아래에 intellij-java-google-style.xml에 있다.
intellij-java-google-style.xml 선택
Scheme를 확인했을때 GoogleStyle이 아니면 아래 화살표를 눌러서 적용
5. Preferences -> Code Style -> Java 선택
6. Tab size와 Indent 조정
Tab size : 4
Indent : 4
Continuation indent : 4
이미 아래와 같이 수정되어있다면 건들이지 않아도 된다.
7. 기존 소스에 format 적용
mac intellij 기준 command + option + L 을 누르면 적용됨