{ // Place your 全局 snippets here. Each snippet is defined under a snippet name and has a scope, prefix, body and // description. Add comma separated ids of the languages where the snippet is applicable in the scope field. If scope // is left empty or omitted, the snippet gets applied to all languages. The prefix is what is // used to trigger the snippet and the body will be expanded and inserted. Possible variables are: // $1, $2 for tab stops, $0 for the final cursor position, and ${1:label}, ${2:another} for placeholders. // Placeholders with the same ids are connected. // Example: // "Print to console": { // "scope": "javascript,typescript", // "prefix": "log", // "body": [ // "console.log('$1');", // "$2" // ], // "description": "Log output to console" // } }
如果没有description,默认提示信息是类似上图中Print to console一样的信息(即key值)
代码多行语句的以 , 隔开
每行代码需要用引号包裹住
字符串间如果值里包含特殊字符需要 \ 进行转义.
下面这些变量可以在snipates中使用:
1 2 3 4 5 6 7 8 9 10 11
TM_SELECTED_TEXT The currently selected text or the emptstring TM_CURRENT_LINE The contents of the current line TM_CURRENT_WORD The contents of the word under cursor othe empty string TM_LINE_INDEX The zero-index based line number TM_LINE_NUMBER The one-index based line number TM_FILENAME The filename of the current document TM_FILENAME_BASE The filename of the current documenwithout its extensions TM_DIRECTORY The directory of the current document TM_FILEPATH The full file path of the current document CLIPBOARD The contents of your clipboard WORKSPACE_NAME The name of the opened workspace or folder
当前日期和时间:
1 2 3 4 5 6 7 8 9 10 11
CURRENT_YEAR The current year CURRENT_YEAR_SHORT The current year’s last two digits CURRENT_MONTH The month as two digits (example ‘02’) CURRENT_MONTH_NAME The full name of the month (example ‘July’) CURRENT_MONTH_NAME_SHORT The short name of the month (example ‘Jul’) CURRENT_DATE The day of the month CURRENT_DAY_NAME The name of day (example ‘Monday’) CURRENT_DAY_NAME_SHORT The short name of the day (example ‘Mon’) CURRENT_HOUR The current hour in 24-hour clock format CURRENT_MINUTE The current minute CURRENT_SECOND The current second
针对当前语言,插入单行或多行注释:
1 2 3
BLOCK_COMMENT_START Example output: in PHP /* or in HTML <!– BLOCK_COMMENT_END Example output: in PHP */ or in HTML --> LINE_COMMENT Example output: in PHP // or in HTML <!-- -->