質問: sublimetextの「ラップ」文字をカスタマイズする sublime textで、テキストを強調表示し、次の記号のいずれかを押します。' " ( { [ ハイライトされたセクション全体が、押したキー(またはそれに対応する記号)で囲まれます。このリストにさらに文字を追加するオプションはありますか? ruby開発では、|と `をかなり頻繁に使用します。
回答: たまたま、バックティック( `)のキーバインドを既に設定しているので、パイプ|のキーバインドを簡単に変更できるはずです。これを行うには、preferences -> key bindings-userを開きます。ファイルが空の場合は、開き角かっこと[]を別々の行に追加し、それらの間に以下を貼り付けます。// auto-pair backticks { "keys": ["`"], "command": "insert_snippet", "args": {"contents": "`$0`"}, "context": [ { "key": "setting.auto_match_enabled", "operator": "equal", "operand": true }, { "key": "selection_empty", "operator": "equal", "operand": true, "match_all": true }, { "key": "following_text", "operator": "regex_contains", "operand": "^(?:\t| |\\)|]|\\}|>|$|;)", "match_all": true }, { "key": "preceding_text", "operator": "not_regex_contains", "operand": "[`a-za-z0-9_]$", "match_all": true }, { "key": "eol_selector", "operator": "not_equal", "operand": "string.quoted.double", "match_all": true } ] }, { "keys": ["`"], "command": "insert_snippet", "args": {"contents": "`${0:$selection}`"}, "context": [ { "key": "setting.auto_match_enabled", "operator": "equal", "operand": true }, { "key": "selection_empty", "operator": "equal", "operand": false, "match_all": true } ] }, { "keys": ["`"], "command": "move", "args": {"by": "characters", "forward": true}, "context": [ { "key": "setting.auto_match_enabled", "operator": "equal", "operand": true }, { "key": "selection_empty", "operator": "equal", "operand": true, "match_all": true }, { "key": "following_text", "operator": "regex_contains", "operand": "^`", "match_all": true } ] }, { "keys": ["backspace"], "command": "run_macro_file", "args": {"file": "res://packages/default/delete left right.sublime-macro"}, "context": [ { "key": "setting.auto_match_enabled", "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 } ] }, パイプ文字の場合、|には特別な意味があるため、一部の正規表現を少し変更する必要があります。以下は私のために働きます:// auto-pair pipes in ruby { "keys": ["|"], "command": "insert_snippet", "args": {"contents": "|$0|"}, "context": [ { "key": "setting.auto_match_enabled", "operator": "equal", "operand": true }, { "key": "selection_empty", "operator": "equal", "operand": true, "match_all": true }, { "key": "following_text", "operator": "regex_contains", "operand": "^(?:\t| |\\)|]|\\}|>|$|;)", "match_all": true }, { "key": "preceding_text", "operator": "not_regex_contains", "operand": "[\\|a-za-z0-9_]$", "match_all": true }, { "key": "eol_selector", "operator": "not_equal", "operand": "string.quoted.double", "match_all": true }, { "key": "selector", "operator": "equal", "operand": "source.ruby", "match_all": true } ] }, { "keys": ["|"], "command": "insert_snippet", "args": {"contents": "|${0:$selection}|"}, "context": [ { "key": "setting.auto_match_enabled", "operator": "equal", "operand": true }, { "key": "selection_empty", "operator": "equal", "operand": false, "match_all": true }, { "key": "selector", "operator": "equal", "operand": "source.ruby", "match_all": true } ] }, { "keys": ["|"], "command": "move", "args": {"by": "characters", "forward": true}, "context": [ { "key": "setting.auto_match_enabled", "operator": "equal", "operand": true }, { "key": "selection_empty", "operator": "equal", "operand": true, "match_all": true }, { "key": "following_text", "operator": "regex_contains", "operand": "^\\|", "match_all": true }, { "key": "selector", "operator": "equal", "operand": "source.ruby", "match_all": true } ] }, { "keys": ["backspace"], "command": "run_macro_file", "args": {"file": "res://packages/default/delete left right.sublime-macro"}, "context": [ { "key": "setting.auto_match_enabled", "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 }, { "key": "selector", "operator": "equal", "operand": "source.ruby", "match_all": true } ] } セレクターsource.rubyを|キーバインディングに追加したことに気付くでしょう-ruby code以外の他のファイルで使用したい場合は、これを削除または変更できます。他の構文で使用できるため、バッククォートコードには追加しませんでした-pythonそしてmarkdownが最初に頭に浮かぶものです。