2017-01-04 2 views
4

サブライムテキストには、新しい行ボタンを押したときに括弧のインデントを処理する3つの方法があります。ST3でブラケットのインデント動作を設定する方法

1.curly私はそれらのすべてを設定することができカーリーブラケット

のように動作する方法ブラケット

xxx = { 
    |cursor| 
} 

2.parenthesis

xxx = (
    |cursor|) 

3.squareブラケット

xxx = [ 
|cursor|] 

答えて

8

De {}カッコの間を入力しを押圧するための機能を提供

{ "keys": ["enter"], "command": "run_macro_file", "args": {"file": "res://Packages/Default/Add Line in Braces.sublime-macro"}, "context": 
    [ 
     { "key": "setting.auto_indent", "operator": "equal", "operand": true }, 
     { "key": "selection_empty", "operator": "equal", "operand": true, "match_all": true }, 
     { "key": "preceding_text", "operator": "regex_contains", "operand": "\\{$", "match_all": true }, 
     { "key": "following_text", "operator": "regex_contains", "operand": "^\\}", "match_all": true } 
    ] 
}, 

:キーバインドを障害、これがあります。マクロは2行の改行を追加し、最初の改行の後にカーソルを移動して改行します。

このため、ユーザーのキーバインドにこれを追加することにより、()[]の間で同じ機能を実現することができます

{ "keys": ["enter"], "command": "run_macro_file", "args": {"file": "res://Packages/Default/Add Line in Braces.sublime-macro"}, "context": 
    [ 
     { "key": "setting.auto_indent", "operator": "equal", "operand": true }, 
     { "key": "selection_empty", "operator": "equal", "operand": true, "match_all": true }, 
     { "key": "preceding_text", "operator": "regex_contains", "operand": "\\($", "match_all": true }, 
     { "key": "following_text", "operator": "regex_contains", "operand": "^\\)", "match_all": true } 
    ] 
}, 
{ "keys": ["enter"], "command": "run_macro_file", "args": {"file": "res://Packages/Default/Add Line in Braces.sublime-macro"}, "context": 
    [ 
     { "key": "setting.auto_indent", "operator": "equal", "operand": true }, 
     { "key": "selection_empty", "operator": "equal", "operand": true, "match_all": true }, 
     { "key": "preceding_text", "operator": "regex_contains", "operand": "\\[$", "match_all": true }, 
     { "key": "following_text", "operator": "regex_contains", "operand": "^\\]", "match_all": true } 
    ] 
}, 
+1

こんにちは。これは私を幾分助けましたが、私はまだ別の行動を取る。括弧で囲まれたものはカーソルでインデントされ、角括弧ではカーソルはまったくインデントされません。 – ViggoV

+0

これは、STがあなたのケースで使用しているインデント規則によるものです@ViggoV - どの言語/構文ですかこの現象が発生していますか? –

+0

Javascript/ES6。私はこれを見つけた:https://stackoverflow.com/questions/22865347/smart-indenting-of-brackets-parenthesis-in-sublime-text-2しかし、それはトリックをしなかった..私はvscodeに戻りました当分の間は... – ViggoV

関連する問題