vscode snippets

Vscode docs on snippets

  1. There are instructions in the snippet file
  2. If you leave them as they are..and add your snippet under it won't work
  3. Delete the comments
  4. Just use the snippet block

your folder/.vscode/file.code-snippets

{
    "Block Comments": {
        "scope": "python",
      "prefix": "block_comments",
        "body": [
            "\"\"\"",
            "*************************************************",
            "* Prep the template",
            "*************************************************",
            "\"\"\""
        ],
        "description": "Inserts a block comment for template preparation."
    }
}

/users/user/appdata/roaming/code/user/snippets/filenam.code-snippets

{
    "Block Comments": {
        "scope": "python",
      "prefix": "block_comments",
        "body": [
            "\"\"\"",
            "*************************************************",
            "* Prep the template",
            "*************************************************",
            "\"\"\""
        ],
        "description": "Inserts a block comment for template preparation."
    },
   "lib_main_snippet": {
         "prefix": "lib_main_snippet",
         "body": [
            "def test():",
            "    pass",
            "",
            "def localTest():",
            "    log.ph1(\"Starting local test\")",
            "    test()",
            "    log.ph1(\"End local test\")",
            "",
            "if __name__ == '__main__':",
            "    localTest()"
         ],
         "description": "Template for local testing with a main block"
      }
}
  1. A single root note
  2. Each snippet is a dictionary entry
  3. Not sure if comments are allowed
  4. Even a small mistake, vscode reports no snippets available...
  5. The whole error messaging could be quite a case in-convalescence.
  1. ctrl-shift-p and "snippets"
  2. use "configure user snippets"
  3. Instead of choosing global you may want to chose your local snippet
  4. this file is saved in .vscode/file.code-snippet
  5. I assume you can have multiple snippet files
  6. Doing locally gives you more access and control to that file where as the global files are tucked away deep inside python global jungle.
  1. Just type the beginning words
  2. intellisense should prompt you right away
  3. No tab is needed
  4. No ctrl-space is needed
  1. Go to settings (ctrl-shift-p: search for settings)
  2. Editor: snippet suggestion
  3. options: top, bottom, inline (default), none
  4. I chose "top"
  5. works good so far