development

Android Studio : 모든 새 클래스에 추가 된 "작성자"주석을 제거 / 업데이트하는 방법은 무엇입니까?

big-blog 2020. 4. 3. 08:19
반응형

Android Studio : 모든 새 클래스에 추가 된 "작성자"주석을 제거 / 업데이트하는 방법은 무엇입니까?


기본적으로 Android Studio는 모든 새 클래스에 헤더 주석을 자동으로 추가합니다 (예 :

/**
 * Created by Dan on 11/20/13.
 */

사용자 정의하거나 제거하기위한 설정은 어디에 있습니까?


메뉴 표시 줄에서 :

  • Mac OS에서 Android Studio->를 선택하십시오.Preferences
  • Windows 및 Linux에서 File->를 선택하십시오.Settings

그런 다음 왼쪽 창에서 Editor-> File and Code Templates찾으 십시오.

이것을 변경할 수있는 두 가지 방법이 있습니다 ...

1) Includes탭을 선택하고 Created by...텍스트를 직접 편집하십시오 .

여기에 이미지 설명을 입력하십시오

2) Templates탭을 선택하고 #parse("File Header.java")원하는 템플릿 라인을 편집하십시오 .

템플릿 탭 편집

개인적으로 나는 옵션 1)을 따르고 기본 헤더 주석을 TODO로 만들었습니다.

/**
 * TODO: Add a class header comment!
 */

이 지침은 Android Studio v0.3.7을 기반으로합니다. 또한 v1.2.1.1에서 테스트되었습니다.


템플릿 파일의 $ {USER} 변수를 #set ($ VARIABLE = "value") 함수로 덮어 쓸 수 있습니다.

On windows: Press Ctrl+Alt+S and go to Settings -> File and Code Templates -> Includes -> File Header

On Mac: Android Studio -> Preferences -> Editor -> 
File and Code Templates -> Includes -> File Header

#set () 함수 호출 앞에 다음을 추가하십시오.

#set( $USER = "YourName" )
/**
* Created by ${USER} on ${DATE}.
*/

Dan의 대답뿐만 아니라 훨씬 엄격한 방법으로 헤더를 클릭하고 옵션 입력 (Mac의 경우)을 클릭하고 기본 파일 템플릿을 편집하도록 선택할 수 있습니다. 또는 작은 전구를 클릭하여 여기로 이동하십시오.

여기에 이미지 설명을 입력하십시오


Android Studio 파일 헤더 템플릿 변경

1 단계 : 먼저 파일 헤더 위로 마우스를 가져간 후 다음 스크린 샷과 같이 노란색 전구와 메뉴를 클릭하여 꺼내십시오.

노란색 전구 메뉴> 템플릿 수정

2 단계 : 그런 다음 템플릿 편집 메뉴 항목을 클릭하면 다음 팝업 창이 나타납니다.

파일 템플릿 편집 팝업 창

Note: In its Description area there are many other available Template variables, you can use them too.

Step 3: In the editor area add your name as shown in the following screenshot and click "OK" button and the current file and the future new class file headers will be generated accordingly.

업데이트 된 헤더 템플릿 구성

Hope this answer will be helpful to somebody else out there! :-) Cheers! (This works on Android Studio 2.2 (September, 2015) version.)


  1. Press ctrl+shift+A
  2. Type : File and Code Templates.
  3. Look for File Header under Includes
  4. You can type something like below

여기에 이미지 설명을 입력하십시오


In case you want to remove all comments which have already been created. Hit Ctrl + Shift + R to open the Replace in path dialog. Check the Regex option and replace

/\*\*\n \* Created by .*\n \*/

with nothing.


The regex was originally posted by nerdinand as comment to the following answer. Although I asked him, he didn't create an answer for several months. That is why I did now, so people can find this more easily.


You can just disable the warning as well. For me the default template was ok but seeing yellow highlighted class javadoc was annoying me. So to disable it go to Settings -> Editor -> Inspections -> General -> Uncheck "Default File Template Usage".

You can also do it accross all projects. Just change the Project profile to Default in the same Inspections tab.


Settings->Editor->Copyright->Copyright Profiles

is another place (apart from "Settings->Editor->File and Code Templates") where similar template could be defined and also triggered whenever file is created.


Accepted answer had instructions for Android Studio v0.3. so I decide to add instructions for Android Studio 3.0.1

  • Go to Android Studio Preferences-> CopyRight->CopyRightProfiles and click on [+] to add a new profile or edit existing profile.

여기에 이미지 설명을 입력하십시오

  • Create or update copyright template, a sample template can be copied from below:

Creator: Hitesh Sahu on $today Last modified: $file.lastModified Copyright: All rights reserved Ⓒ $today.year http://hiteshsahu.com

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

여기에 이미지 설명을 입력하십시오

  • Now select that newly created copyright as your default copyright profile

    여기에 이미지 설명을 입력하십시오

  • Lastly update copyright of entire project like below

    여기에 이미지 설명을 입력하십시오

참고URL : https://stackoverflow.com/questions/20109203/android-studio-how-to-remove-update-the-created-by-comment-added-to-all-new-c

반응형