美文网首页
VSCode Snippets Variables

VSCode Snippets Variables

作者: 学点笔记 | 来源:发表于2020-10-26 04:43 被阅读0次

    With $name or ${name:default}, you can insert the value of a variable. When a variable isn't set, its default or the empty string is inserted. When a variable is unknown (that is, its name isn't defined) the name of the variable is inserted and it is transformed into a placeholder.

    The following variables can be used:

    • TM_SELECTED_TEXT The currently selected text or the empty string
    • TM_CURRENT_LINE The contents of the current line
    • TM_CURRENT_WORD The contents of the word under cursor or the 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 document without its extensions
    • TM_DIRECTORY The directory of the current document
    • TM_FILEPATH The full file path of the current document
    • CLIPBOARDThe contents of your clipboard
    • WORKSPACE_NAME The name of the opened workspace or folder

    For inserting the current date and time:

    • 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
    • CURRENT_SECONDS_UNIX The number of seconds since the Unix epoch

    For inserting line or block comments, honoring the current language:

    • LINE_COMMENT Example output: in PHP//

    The snippet below inserts /* Hello World */ in JavaScript files and

    <!-- Hello World -->
    

    in HTML files:

    {
      "hello": {
        "scope": "javascript,html",
        "prefix": "hello",
        "body": "$BLOCK_COMMENT_START Hello World $BLOCK_COMMENT_END"
      }
    }
    

    More-->https://code.visualstudio.com/docs/editor/userdefinedsnippets

    相关文章

      网友评论

          本文标题:VSCode Snippets Variables

          本文链接:https://www.haomeiwen.com/subject/uubomktx.html