Configuration
Search for hiasConsoleLog in VSCode settings, or edit settings.json
directly:
json
{
"hiasConsoleLog": {
// Enable the extension
"enable": true,
// console.log argument template
"template": "${value}, `${name}`",
// Copy extracted content to clipboard after insertion
"copyToClipboard": false,
// Clipboard extraction pattern
"clipboardPattern": ""
}
}
hiasConsoleLog.enable
- Type:
boolean - Default:
true
Master switch. When disabled, all commands are no-ops.
hiasConsoleLog.template
- Type:
string - Default:
${value}, \${name}``
The console.log argument template that shapes the inserted statement.
Variables
| Variable | Description |
|---|---|
${value} |
The selected text |
${name} |
The original text (used as a label) |
${name:prefix,suffix} |
Original text with prefix/suffix, e.g. ${name:log_,} → log_obj
|
Snippet Syntax
VSCode snippet syntax controls the cursor after insertion:
| Syntax | Description |
|---|---|
$1, $2 |
Tab stops, visited in order |
${1:placeholder} |
Tab stop with placeholder text |
$0 |
Final cursor position |
TIP
A trailing $0 is automatically moved after the closing ), so the
cursor ends up at the end of the statement instead of inside the parentheses.
Examples
| Template | Result (selecting obj) |
|---|---|
${value}, \${name}`` |
console.log(obj, \obj`)` |
'>>> ${name}', ${value} |
console.log('>>> obj', obj) |
${value}, \${name:log_,}`` |
console.log(obj, \log_obj`)` |
${value}$1, \${name}`$0` |
Same as default, cursor stops at $1 |
hiasConsoleLog.copyToClipboard
- Type:
boolean - Default:
false
Whether to extract content via clipboardPattern and copy it to the clipboard after
insertion.
hiasConsoleLog.clipboardPattern
- Type:
string - Default:
""(no copy)
Clipboard extraction pattern. Uses the same variable syntax as template, plus:
| Variable | Description |
|---|---|
${line} |
The full console.log statement |
Example
json
{
"hiasConsoleLog": {
"template": "${value}, `${name:log_,}`",
"copyToClipboard": true,
"clipboardPattern": "${name:log_,}"
}
}
Selecting params copies log_params to the clipboard.