Skip to content

CodeOTR/cotr-snippets

Repository files navigation

Code on the Rocks

Rust Swift TypeScript JavaScript Dart Go Kotlin Python C++ C# Java PHP Ruby R Scala Markdown

At Code on the Rocks (COTR) our mission is to enable developers to code fluently in every programming language. We create tools and resources to help you apply your high-level programming knowledge in any code base.

COTR Integration

Code on the Rocks is a social platform for developers to share, remix, and edit code snippets. This VS Code extension provides a simple command (Save COTR Snippet) to convert code from VS Code into COTR snippets.

To use it, simply highlight the code you want to save, right-click, and select the Save COTR Snippet command. This will open the COTR website with your code. At this point, you can save, screenshot, and update the code using our AI models.

By default, snippets will be save anonymously so a COTR account isn't required. If you'd like to save snippets to your own account, create an account on the COTR Website and then use the Login to COTR command in VS Code to connect your account.

COTR Snippets

This extension also provides a large list of generic snippets that can be used in any project, regardless of the language used.

How does it work?

Each snippet is implemented separately in each language. This means that if you are working in a TypeScript file, you will get TypeScript-specific snippets. If you are working in a Rust file, you will get Rust-specific snippets. This allows you to use the same snippet prefix in different languages and get the correct snippet for the language you are working in.

Check out the official docs for more information.

COTR Snippets

Supported Languages

Language File Extensions VS Code Extension
Dart .dart Dart Code
Swift .swift Swift Language
JavaScript .js Built-in
JavaScript React (JSX) .jsx VSCode React Refactor
TypeScript .ts Built-in
TypeScript React (TSX) .tsx TypeScript TSLint Plugin
Go .go Go
Rust .rs, .rlib Rust
Kotlin .kt, .kts Kotlin
Python .py Python
C++ .cpp, .hpp, .cc, .hh, .cxx, .hxx, .c++, .h++ C/C++
C# .cs C#
Java .java Language Support for Java(TM) by Red Hat
PHP .php PHP Intelephense
Ruby .rb Ruby
R .r R
Scala .scala, .sc Scala (Metals)
Markdown .md Built-in
Haskell .hs Haskell Syntax Highlighting
PowerShell .ps1 PowerShell
Perl .pl Perl

Snippets

Each snippet has multiple aliases but you can see them all by typing the "cotr" prefix. Aliases are written in plain english and are easy to remember. For example, the cotrPrint snippet can be accessed by typing "cotrPrint", "print", "log", "out", and "write".

Name Description
cotrInfo Outputs information about the language
cotrStructure Outputs the basic structure for a project
cotrOperators Outputs the basic operators for the language
cotrOperatorsBool Outputs the basic boolean operators for the language
cotrEqual Outputs the equality operator for the language
cotrNotEqual Outputs the not equal operator for the language
cotrEntry Creates a main entry point
cotrTypeCheck Outputs the basic syntax for type checking
cotrTypeCompare Outputs the basic syntax for type comparison
cotrTypeConvert Outputs the basic syntax for type conversion
cotrTypes The language's data types
cotrTypesString The language's string data type
cotrTypesInt The language's integer data type
cotrTypesNum The language's numerical data type
cotrTypesBool The language's boolean data type
cotrTypesBoolTrue The language's value for true
cotrTypesBoolFalse The language's value for false
cotrTypesDate The language's Date data type
cotrTypesList The language's list data type
cotrTypesMap The language's map data type
cotrTypesDynamic The language's dynamic data type
cotrTypesNull The language's nullable data type
cotrNow How the language represents the current time
cotrVar Creates a variable
cotrVarSyntax Outputs the basic syntax for a variable
cotrVarTyped Creates a statically typed variable
cotrVarNullable Creates a nullable variable
cotrVarString Creates a string variable
cotrVarStringMulti Creates a multi-line string variable
cotrVarNum Creates a number variable
cotrVarBool Creates a boolean variable
cotrVarDate Creates a date variable
cotrVarList Creates a list variable
cotrVarMap Creates a map variable
cotrConst Creates a constant variable
cotrVarStatic Creates a static variable
cotrGenMap Generates a map/dictionary with a specific number of key/value pairs
cotrGenList Generates a list/array of a specific length
cotrPrint Creates a print/log statement
cotrPrintMulti Creates a multi-line print/log statement
cotrInterpolate Interpolates a string
cotrConcat Concatenates a string
cotrForLoop Creates a for loop
cotrForIn Creates a for-in/of loop
cotrWhileLoop Creates a while loop
cotrSwitch Creates a switch stament with default
cotrFunc Creates a function
cotrFuncArgs Creates a function with arguments
cotrFuncArgsNamed Creates a function with named arguments
cotrFuncArrow Creates an arrow function
cotrFuncAnon Creates an anonymous function
cotrFuncLambda Creates a lambda function
cotrFuncSyntax Outputs the basic syntax for a function
cotrComment Creates a single-line comment
cotrCommentMulti Creates a multi-line comment
cotrThrow Throws an exception
cotrTryCatch Creates a try-catch block
cotrIf Creates an if statement
cotrIfElse Creates an if-else statement
cotrTernary Creates a ternary statement

If a language does not support the snippet, a comment will be added to the file indicating that the snippet is not supported. Additional resources may also be provided.