Skip to content

Latest commit

 

History

History
181 lines (125 loc) · 2.9 KB

reference.md

File metadata and controls

181 lines (125 loc) · 2.9 KB

Documentation

In this documentation, $1 represents the first tabbed input, all the way to $n. $0 represents the last place you end up in after you’re done tabbing. If there are two $n, e.g. $1 f($1), then that means a caret will be created at each of these locations. If you see ${2:$1} then that means that you can input part of $2 first, in this case $1, and then tab over to the whole expression, which in this case is $2.

To activate a snippet just type the trigger and then press tab button.

Although the snippets show up as having four spaces in the reference, in the actual snippet it will substitute it with your used setting.

Table of Contents

Loops #

A collection of loop auto completions.

Trigger: for

for i in list_:
    #codes

Trigger: while

while True:
    #do something

Trigger: range

for i in range(count):
    #code

Utilities #

Utilities will be uploading day by day, not only basic python snippets but also for different libraries

Trigger: append

list.append(element)

Trigger: intersect

def intersect(arr1, arr2):
  return [x for x in arr1 if x in arr2]

Trigger: try

try:
    #code
except Exception as e:
    raise e
else:
    pass

Trigger: with

with open("file", "r") as f:
    data = f.read()

Trigger: from

from module import Class

Conditional Statements #

Trigger: if

if True:
     #code 

Trigger: ifelse

if True :
    #code

else :
    #code

Trigger: ifelif

if True :
    #code

elif False :
    #code

else :
    #code

Classes #

Trigger: class

class ClassName(object) :
    def __init__(self, arg):
        super(ClassName, self).__init__()
        self.arg = arg
    def function(param):
        #Code

Trigger: @classmethod

    @classmethod
    def argument(cls):
        #code
        return cls.arg

Trigger: @staticmethod

    @staticmethod
    def static_method(*args, **kwargs):
        #code
        return args

Lambda #

Snippets to insert Python3 lambdas of different flavours.

Trigger: lmax

max(list_, key=lambda s: x['rating'])

Trigger: lmin

min(list_, key=lambda s: x['rating'])

Functions #

Trigger: def

def function_name(*args, **kwargs) :
    def

Trigger: async

async def func(param1, param2):
    #await some_coroutine()
    #code