Skip to content

Instantly share code, notes, and snippets.

@hrishikeshrt
Last active June 9, 2021 18:52
Show Gist options
  • Save hrishikeshrt/1327ce19fa2828eae7956f7c134776c7 to your computer and use it in GitHub Desktop.
Save hrishikeshrt/1327ce19fa2828eae7956f7c134776c7 to your computer and use it in GitHub Desktop.
Python User Snippet for VSCode

Instructions

  • Location: File > Preferences > User Snippets > python.json
  • Location on disk: ~/.config/Code/User/snippets/
  • Copy Line 15 to 30 and paste in python.json if it exists, else create and copy entire contents.
{
// Place your snippets for python here. Each snippet is defined under a snippet name and has a prefix, body and
// description. 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": {
// "prefix": "log",
// "body": [
// "console.log('$1');",
// "$2"
// ],
// "description": "Log output to console"
// }
"New python file": {
"prefix": "new:py",
"body": [
"#!/usr/bin/env python3",
"# -*- coding: utf-8 -*-",
"\"\"\"",
"Created on $CURRENT_DAY_NAME_SHORT $CURRENT_MONTH_NAME_SHORT $CURRENT_DATE $CURRENT_HOUR:$CURRENT_MINUTE:$CURRENT_SECOND $CURRENT_YEAR",
"",
"@author: Hrishikesh Terdalkar",
"\"\"\"",
"",
"###############################################################################",
"",
],
"description": "Start a new python file"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment