bmalehorn / vscode-print-it

Wrap a print statment around current word or selection

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

VSCode Print It

version number install count

Add print statements in one keystroke!

[, Alt [: wrap print statement

Demo

demo

Supported Languages

language example
JavaScript console.log("variable", variable);
TypeScript console.log("variable", variable);
React console.log("variable", variable);
Vue console.log("variable", variable);
HTML console.log("variable", variable);
Python print("variable", variable)
Mojo print("variable", variable)
Go fmt.Printf("variable %#v\n", variable)
Ruby pp('variable', variable)
Java System.out.format("variable %s\n", variable);
PHP echo "\$variable "; print_r($variable); echo "\n";
C# Console.WriteLine("variable {0}", variable);
C++ std::cout << "variable " << variable << std::endl;
Rust println!(\"variable {:?}\", raw);
Dart print("variable = ${variable}");
Kotlin System.out.format("variable %s\n", variable)
Elixir IO.puts "variable " <> inspect(variable)
Bash echo "variable $variable"
Fish echo "variable $variable"

Templating

Want to change the default formatting? Set the configuration option print-it.[language].template:

  "print-it.javascriptreact.template": "console.log(\"The value of {{escaped}} is:\", {{raw}});"

This will make new print statements look like this:

console.log("The value of variable is:", variable);

A full list of supported options is available under the "Contributions" tab.

The following variables are available:

variable example exaplanation
{{raw}} "hello " + name the current selection, or current word
{{escaped}} \"hello \" + name raw, but escaped for use in a string

For all other languages, you can set the value of print-it.default.template:

  "print-it.default.template": "printf(\"{{escaped}} %s\\n\", {{raw}});"

Related Projects

About

Wrap a print statment around current word or selection


Languages

Language:TypeScript 72.2%Language:Vue 3.8%Language:Rust 3.6%Language:C# 3.3%Language:Java 3.1%Language:C++ 2.9%Language:Shell 1.8%Language:HTML 1.4%Language:PHP 1.2%Language:Kotlin 1.2%Language:C 1.1%Language:Go 1.0%Language:Python 0.9%Language:Elixir 0.9%Language:JavaScript 0.8%Language:Dart 0.6%Language:Ruby 0.3%