Cover Image

Contents

Introduction

One of the most essential debugging tools is the print statement. Being able to print something to the console quickly without questioning the syntax is a skill many developers hone early on. Unfortunately, not all languages print the same.

The cotr-snippets VS Code extension includes two snippets to help reduce the friction of moving to a new programming language:

  • cotrPrint: Prints a single line of text to the console
  • cotrPrintMulti: Prints a multi-line text to the console

This article shows what each of these snippets creates in all of the supported COTR languages.

Languages

Dart

cotrPrint

The cotrPrint snippet in Dart creates the following code:

print('Your message here');

This will print a single line of text to the console in Dart.

cotrPrintMulti

The cotrPrintMulti snippet in Dart creates the following code:

print('''
Line 1
Line 2
Line 3
''');

This will print multiple lines of text to the console in Dart, with each string on a new line.

JavaScript

cotrPrint

The cotrPrint snippet in JavaScript creates the following code:

console.log('Your message here');

This will print a single line of text to the console in JavaScript.

cotrPrintMulti

The cotrPrintMulti snippet in JavaScript creates the following code:

console.log(`
Line 1
Line 2
Line 3
`);

This will print multiple lines of text to the console in JavaScript, with each string on a new line.

TypeScript

cotrPrint

The cotrPrint snippet in TypeScript creates the following code:

console.log('Your message here');

This will print a single line of text to the console in TypeScript.

cotrPrintMulti

The cotrPrintMulti snippet in TypeScript creates the following code:

console.log(`
Line 1
Line 2
Line 3
`);

This will print multiple lines of text to the console in TypeScript, with each string on a new line.

Rust

cotrPrint

The cotrPrint snippet in Rust creates the following code:

println!("Your message here");

This will print a single line of text to the console in Rust.

cotrPrintMulti

The cotrPrintMulti snippet in Rust creates the following code:

println!("
Line 1
Line 2
Line 3
");

This will print multiple lines of text to the console in Rust, with each string on a new line.

Go

cotrPrint

The cotrPrint snippet in Go creates the following code:

fmt.Println("Your message here")

This will print a single line of text to the console in Go.

cotrPrintMulti

The cotrPrintMulti snippet in Go creates the following code:

fmt.Println(`
Line 1
Line 2
Line 3
`)

This will print multiple lines of text to the console in Go, with each string on a new line.

C++

cotrPrint

The cotrPrint snippet in C++ creates the following code:

std::cout << "Your message here" << std::endl;

This will print a single line of text to the console in C++.

cotrPrintMulti

The cotrPrintMulti snippet in C++ creates the following code:

std::cout << "
Line 1
Line 2
Line 3
" << std::endl;

This will print multiple lines of text to the console in C++, with each string on a new line.

C#

cotrPrint

The cotrPrint snippet in C# creates the following code:

Console.WriteLine("Your message here");

This will print a single line of text to the console in C#.

cotrPrintMulti

The cotrPrintMulti snippet in C# creates the following code:

Console.WriteLine(@"
Line 1
Line 2
Line 3
");

This will print multiple lines of text to the console in C#, with each string on a new line.

PHP

cotrPrint

The cotrPrint snippet in PHP creates the following code:

echo "Your message here";

This will print a single line of text to the console in PHP.

cotrPrintMulti

The cotrPrintMulti snippet in PHP creates the following code:

echo "
Line 1
Line 2
Line 3
";

This will print multiple lines of text to the console in PHP, with each string on a new line.

Python

cotrPrint

The cotrPrint snippet in Python creates the following code:

print('Your message here')

This will print a single line of text to the console in Python.

cotrPrintMulti

The cotrPrintMulti snippet in Python creates the following code:

print('''
Line 1
Line 2
Line 3
''')

This will print multiple lines of text to the console in Python, with each string on a new line.

Java

cotrPrint

The cotrPrint snippet in Java creates the following code:

System.out.println("Your message here");

This will print a single line of text to the console in Java.

cotrPrintMulti

The cotrPrintMulti snippet in Java creates the following code:

System.out.println("
Line 1
Line 2
Line 3
");

This will print multiple lines of text to the console in Java, with each string on a new line.

Kotlin

cotrPrint

The cotrPrint snippet in Kotlin creates the following code:

println("Your message here")

This will print a single line of text to the console in Kotlin.

cotrPrintMulti

The cotrPrintMulti snippet in Kotlin creates the following code:

println("""
Line 1
Line 2
Line 3
""")

This will print multiple lines of text to the console in Kotlin, with each string on a new line.

Swift

cotrPrint

The cotrPrint snippet in Swift creates the following code:

print("Your message here")

This will print a single line of text to the console in Swift.

cotrPrintMulti

The cotrPrintMulti snippet in Swift creates the following code:

print("""
Line 1
Line 2
Line 3
""")

This will print multiple lines of text to the console in Swift, with each string on a new line.