숭고한 텍스트: 줄 바꾸기 및 들여쓰기

숭고한 텍스트: 줄 바꾸기 및 들여쓰기

나는 최근에 원자를 시험해 보았습니다. 너무 느렸음에도 불구하고 제가 좋아하는 한 가지가 있었습니다. 기본적으로 모든 곳에서 자동 들여쓰기가 작동하는 방식이었습니다.

나는 찾았다여기Paste + Indent the default숭고한 텍스트로 만드는 방법 .

그러나 나는 또한 다음을 원합니다:

{ "keys": ["ctrl+shift+up"], "command": "swap_line_up" },
{ "keys": ["ctrl+shift+down"], "command": "swap_line_down" },

내가 가지고 있는 경우 swap_line_up_and_indent:

console.log('hello');
function() {

}

그리고 나는 ctrl+shift+down다음을 얻습니다:

function() {
  console.log('hello'); // indented yai!!
}

어떤 기회?

답변1

따라서 이를 수행하는 가장 쉬운 방법은 (다소 광범위한 플러그인을 작성하는 것 외에) 다음과 같습니다.매크로. 여기 있습니다 swap_line_down_and_indent.sublime-macro:

[
    {
        "command": "swap_line_down"
    },
    {
        "command": "indent"
    }
]

그리고 swap_line_up_and_indent.sublime-macro:

[
    {
        "command": "swap_line_up"
    },
    {
        "command": "move",
        "args":
        {
            "by": "lines",
            "forward": true
        }
    },
    {
        "command": "indent"
    }
]

선택 시 폴더가 열린 Packages/User위치 에 파일을 저장합니다.PackagesPreferences → Browse Packages…. 그런 다음 다음을 사용하여 사용자 정의 키맵을 편집하십시오.

{ 
    "keys": ["ctrl+shift+up"], 
    "command": "run_macro_file", 
    "args": 
    {
        "file": "res://Packages/User/swap_line_up_and_indent.sublime-macro"
    } 
},
{ 
    "keys": ["ctrl+shift+down"], 
    "command": "run_macro_file", 
    "args": 
    {
        "file": "res://Packages/User/swap_line_down_and_indent.sublime-macro"
    } 
}

이제 모든 준비가 완료되었습니다. 하지만 몇 가지 주의 사항이 있습니다. 이러한 매크로는 한 수준만 들여쓰기하므로 Ctrl]줄을 더 들여쓰려면 를 사용해야 할 수도 있습니다 . 또한 들여쓰기할 줄은 swap_line_[up|down]명령 실행 후 아래쪽 줄인 것으로 가정합니다 .

답변2

'Chain of Command' 패키지를 사용하여 이 작업을 수행할 수도 있습니다. 패키지를 설치하고 사용자 키 바인딩 파일에 다음을 추가하세요.

{
   "keys": ["ctrl+super+up"], 
   "command": "chain", 
   "args": {
     "commands": [
       ["swap_line_up"],
       ["reindent", {"single_line": false}]
     ],
   },
 },
{
  "keys": ["ctrl+super+down"], 
  "command": "chain", 
  "args": {
    "commands": [
      ["swap_line_down"],
      ["reindent", {"single_line": false}]
    ],
  },
}

관련 정보