snippets
The community/core/snippets/snippets
directory contains a collection of code snippets designed to be used with a text editor or IDE. These snippets are used to quickly insert common code structures. Each snippet is defined in its own file, named with a .snippet
extension.
The snippets are language-aware, meaning that the code inserted will vary based on the language selected when using the snippet. Most of the snippets have multiple language versions included in the same file.
Here's a breakdown of some of the most interesting or important snippets:
-
tryStatement.snippet
: Inserts atry
block for JavaScript, Java, and Python. -
global.snippet
: Inserts a code block. It uses markdown code fence. -
constructorDeclaration.snippet
: Inserts a constructor declaration for JavaScript, Java, and Python. -
formatString.snippet
: Inserts a formatted string for JavaScript, Java, and Python. -
throwException.snippet
: Inserts a statement to throw an exception in JavaScript, Python, and Java. -
commentBlock.snippet
: Inserts a multi-line comment block for C, Javascript, Java, Python, and HTML. -
ifStatement.snippet
: Inserts anif
statement for JavaScript, Java, Python, and Lua. -
forLoopStatement.snippet
: Inserts afor
loop for JavaScript, Java, and Python. -
functionDeclaration.snippet
: Inserts a function declaration for JavaScript, Java, and Python. -
elseIfStatement.snippet
: Inserts anelse if
statement for JavaScript, Java, Python, and Lua. -
typescript.snippet
: Contains a snippet for a Typescript interface declaration. -
javascript.snippet
: Contains multiple JavaScript specific snippets, includingforInLoopStatement
,anonymousFunctionDeclarationAndCall
,importStarStatement
,importFromStatement
,namedLambdaExpression
,reactUseState
, andreactUseEffect
. -
lua.snippet
: Contains Lua specific snippets, includingforInIPairs
andforInPairs
. -
commentDocumentation.snippet
: Inserts a documentation comment for Javascript, Java, and Python. -
catchStatement.snippet
: Inserts acatch
block for JavaScript, Java, and Python. -
elseStatement.snippet
: Inserts anelse
statement for JavaScript, Java, Python, and Lua. -
markdown.snippet
: Contains a snippet for inserting a markdown link. -
forEachStatement.snippet
: Inserts afor each
loop for JavaScript, Java, and Python. -
whileLoopStatement.snippet
: Inserts awhile
loop for Javascript, Java, and Python. -
printStatement.snippet
: Inserts a print statement for Javascript, Java, Python, and Talon. -
switchStatement.snippet
: Inserts aswitch
statement for Javascript, Java, and Python. -
functionCall.snippet
: Inserts a function call for C, Javascript, Java, Python, and Talon. -
classDeclaration.snippet
: Inserts a class declaration for JavaScript, Java, and Python. -
talon.snippet
: Contains a Talon specific snippet for a voice command declaration. -
defaultStatement.snippet
: Inserts a default case for Javascript, Java, and Python. -
commentLine.snippet
: Inserts a single line comment for C, Javascript, Java, Json, Python, Talon, csv, HTML, and scm. -
tryCatchStatement.snippet
: Inserts atry catch
block for JavaScript, Java, and Python. -
newInstance.snippet
: Inserts a statement to create a new instance for JavaScript, Java, and Python. -
item.snippet
: Inserts an item in a collection for Javascript and Python. -
python.snippet
: Contains multiple Python specific snippets, includingtalonAppDeclaration
,talonModuleClass
,talonContextMatch
,talonContextList
, andtalonContextClass
. -
html.snippet
: Contains multiple HTML specific snippets, includingelement
,attribute
,table
, andunorderedList
. -
finallyStatement.snippet
: Inserts afinally
block for Javascript, Java, and Python. -
ternary.snippet
: Inserts a ternary operator for Javascript, Python, and Lua. -
doWhileLoopStatement.snippet
: Inserts ado while
loop for Javascript and Java. -
methodDeclaration.snippet
: Inserts a method declaration for JavaScript. -
caseStatement.snippet
: Inserts acase
statement for Javascript, Java, and Python. -
lambdaExpression.snippet
: Inserts a lambda expression for JavaScript, Java, and Python.
These snippets aim to increase development speed by providing easy access to common code structures. They are also designed to be language-aware, providing the appropriate syntax for a given language.