Romly-RegexpSearchTemplate.templates
Define templates executed by this extension. This will be an array contains JSONs which has definition like below. A single template can hold multiple regular expression which are executed at once, and supported file-extensions.
実行できる正規表現テンプレートのリストを定義します。これは下記のような定義を持つJSONの配列です。ひとつのテンプレートには一度に実行する複数の正規表現と対応する拡張子を指定できます。
label
A name of template. This will be used if a template does not found for a editing file, or multiple templates are found.
テンプレートの名前です。対応する拡張子が見つからなかった場合や複数のテンプレートが該当した時に選択する為に使用されます。
extensions
Template will be executed if a file-extension for current editing file was found in this extension array. User can choose a template when execution if same file-extensions are specified in multiple templates.
編集中のファイルの拡張子がこの拡張子リストに存在する場合、このテンプレートによる正規表現検索が実行されます。複数のテンプレートで同じ拡張子が定義されていた場合は実行時に選択肢が表示されます。
templates
One or more regular expressions which will be executed by this template at once. The JSON object array each has three fields below.
このテンプレートで実行する一つ以上の正規表現です。下記の3つの値を持つJSONオブジェクトの配列です。
name
pattern
A regular expression which will be executed. Notice that backslashes "\" must be escaped.
実行する正規表現です。バックスラッシュ( \ )をエスケープする必要がことに注意してください。
label
A text label when its result is shown in the command palette. You can use regular expression captures like $0
..$9
and also icons which is defined by VS code such as $(symbol-method)
.
検索結果をコマンドパレットに表示する時のテキストです。$0
~$9
の正規表現のキャプチャや、VS Codeで定義されているアイコン($(symbol-method)
など)が使えます。
Below is an example of templates. These templates will be added to the settings as a sample when you choose 'Yes' to the confirmation that will show when no templates were found.
templatesの例を下記に示します。このテンプレートは、テンプレートが見つからなかった場合に表示される確認で「はい」を選択するとサンプルとして設定に追加されます。
"Romly-RegexpSearchTemplate.templates":
[
{
"label": "C#",
"templates":
[
{
"name": "C# class name",
"label": "$(symbol-class) $1",
"pattern" : "^\\s*(?:private|public)\\sclass\\s([\\w]+)\\s\\:",
"label_index" : 1
},
{
"name": "C# default method",
"label": " $(symbol-method) $1$3",
"pattern" : "^\\s*(private\\s|public\\s|)([\\w]+)\\s([\\w]+)\\(",
"label_index" : 3
},
{
"name": "C# public property",
"label": " $(symbol-field) public $2",
"pattern" : "^\\s*public\\s([\\w]+)\\s([\\w]+)$",
"label_index" : 2
}
],
"extensions": [".cs"]
},
{
"label": 'Delphi',
"extensions": [".pas"],
"templates":
[
{
"name": "Delphi procedure",
"pattern": "^procedure\\s(\\w+)\\.(?!FormCreate)(\\w+)",
"label": "$(symbol-method) $1 $2"
},
{
"name": "Delphi function",
"pattern": "^function\\s(\\w+)\\.(\\w+)",
"label": "$(symbol-function) $1 $2"
},
{
"name": "Delphi FormCreate",
"pattern": "^procedure\\s(\\w+)\\.FormCreate",
"label": "$(window) $1 FormCreate"
},
{
"name": "Delphi constructor",
"pattern": "^constructor\\s(\\w+)\\.(\\w+)",
"label": "$(symbol-constructor) $1 $2"
},
{
"name": "Delphi destructor",
"pattern": "^destructor\\s(\\w+)\\.(\\w+)",
"label": "$(x) $1 $2"
},
{
"name": "Delphi sub method",
"pattern": "^((?:[ ]{2})*)(?:procedure|function)\\s([\\w]+)[;\\(]",
"label": "$(symbol-method) $1$1$1$1$2"
}
]
},
{
"label": 'Python',
"extensions": [".py"],
"templates":
[
{
"name": "Python def",
"pattern": "(\\t*)def\\s(\\w+)",
"label": "$(symbol-method) $1$2"
},
{
"name": "Python class",
"pattern": "class\\s(\\w+)",
"label": "$(symbol-class) $1"
}
]
},
{
"label": 'Python const',
"extensions": [".py"],
"templates":
[
{
"name": "Python const",
"pattern": "^([A-Z_]+)\\s=\\s[^'\\d\\[]",
"label": "$(symbol-constant) $1"
},
{
"name": "Python const int",
"pattern": "^([A-Z_]+)\\s=\\s[\\d.]+",
"label": "$(symbol-number) $1"
},
{
"name": "Python const str",
"pattern": "^([A-Z_]+)\\s=\\s'(.*)'",
"label": "$(symbol-string) $1"
},
{
"name": "Python const array",
"pattern": "^([A-Z_]+)\\s=\\s\\[",
"label": "$(symbol-array) $1"
}
]
},
{
"label": 'Processing',
"extensions": [".pde"],
"templates":
{
"name": "Processing Method",
"pattern": "^\\w+\\s(\\w+)\\(",
"label": "$(symbol-method) $1"
}
},
{
"label": "CPP",
"extensions": [".cpp", ".ino"],
"templates":
[
{
"label": "$(symbol-constructor) $1 constructor",
"pattern" : "^(\\w+)\\:\\:(\\w+)",
"label_index" : 1
},
{
"label": "$(symbol-constructor) $1 destructor",
"pattern" : "^(\\w+)\\:\\:(~\\w+)",
"label_index" : 1
},
{
"label": "$(symbol-class) $1 :: $2",
"pattern" : "^\\w+\\s\\*?(\\w+)\\:\\:(\\w+)\\(",
"label_index" : 1
},
{
"label": "$(symbol-method) $1",
"pattern" : "^\\w+\\s\\*?(\\w+)\\([^\\;]+$",
"label_index" : 1
},
{
"label": "前方宣言 $1",
"pattern" : "^\\w+\\s\\*?(\\w+)\\(.+\\;$",
"label_index" : 1
}
]
},
{
"label": "HTML",
"extensions": [".html"],
"templates":
[
{
"label": "$1",
"pattern" : "<h1[^>]*>(.*)<\\/h1>",
"label_index" : 1
},
{
"label": " $1",
"pattern" : "<h2[^>]*>(.*)<\\/h2>",
"label_index" : 1
},
{
"label": " $1",
"pattern" : "<h3[^>]*>(.*)<\\/h3>",
"label_index" : 1
},
{
"label": " $1",
"pattern" : "<h4[^>]*>(.*)<\\/h4>",
"label_index" : 1
}
]
},
{
"label": "TypeScript",
"extensions": [".ts"],
"templates":
[
{
"label": "$(symbol-method) $1",
"pattern": "^function (\\w+)\\(",
"label_index": 1
}
],
},
{
"label": "CSS",
"extensions": [".css", ".scss"],
"templates":
[
{
"label": "$0",
"pattern": "^(\\t?[\\.#\\w\\[\\]\\-\\=\\(\\)\\: ]+)[ \\t]*{?\\n",
"label_index": 0
},
{
"label": "$0",
"pattern": "^\\t+\\&[\\w\\-]+",
"label_index": 0
},
{
"label": "@mixin $1",
"pattern": "@mixin\\s+(\\w+)\\(.*\\)",
"label_index": 0
}
],
}
]
See VS code extension settings screen for the other settings for this extension.
その他の設定は拡張機能の設定画面の説明をご覧下さい。