본문 바로가기

# 미사용

서브라임 텍스트 3 정규식 바꾸기 매크로 RegReplace


 Reg Replace 플러그인


Reg Replace 플러그인은 여러개의 바꾸기 작업을 매크로처럼 사용할 수 있도록 도와준다.


유저는 각각의 replace rule을 만들고,

이것을 command로 묶어서 실행시킬 수 있다.



 설치하기

Installation

Package Control

The recommended way to install RegReplace is via Package Control. Package Control will install the correct branch on your system and keep it up to date.

  1. Ensure Package Control is installed. Instructions are found here.

  2. In Sublime Text, press CtrlShiftP (Win, Linux) or CmdShiftP(OSX) to bring up the quick panel and start typing Package Control: Install Package. Select the command and it will show a list of installable plugins.

  3. Start typing RegReplace; when you see it, select it.

  4. Restart to be sure everything is loaded properly.

  5. Enjoy!



 룰 설정하기

[Preferences]

    - [Package Settings] 

    - [RegReplace] 

    - [Rules User]


가장 작은 바꾸기 작업이다.

정규식을 통해 바꾸기 작업을 정의할 수 있다.


greedy는 모두 바꾸기 기능.


{
    // html replace.
    "format": "3.0",
    "replacements": {
        // rule : 부등호(1)
        "replace_lt" : {
            "find" : "& lt;",
            "replace" : "<",
            "greedy" : true
        },


        // rule : 부등호(2)
        "replace_gt" : {
            "find" : "& gt;",
            "replace" : ">",
            "greedy" : true
        },


        // rule : 앰퍼센드
        "replace_amp" : {
            "find" : "& amp;",
            "replace" : "&",
            "greedy" : true
        },


        // rule : 큰 따옴표
        "replace_quot" : {
            "find" : "\"",
            "replace" : """,
            "greedy" : true
        },


        // rule : 작은 따옴표
        "replace_apos" : {
            "find" : "'",
            "replace" : "'",
            "greedy" : true
        }
    }
}



 커맨드 설정하기

[Preferences]

    - [Package Settings] 

    - [RegReplace] 

    - [Commands User]


위에서 설정한 규칙들은 하나의 명령어처럼 묶어서 사용할 수 있다.

[
    {
        "caption": "Reg Replace: html escape",
        "command": "reg_replace",
        "args": {"replacements": ["replace_amp", "replace_lt", "replace_gt","replace_quot", "replace_apos"]}
    }
]



 커맨드 호출하기

 CtrlShiftP 를 누르고 자신이 설정한 캡션을 타이핑한다. 


[바꾸기 전]



[바꾸기 후]