Skip to content

Instantly share code, notes, and snippets.

@sblack4
Created April 15, 2021 17:30
Show Gist options
  • Save sblack4/305025c3956341f8a5c85379b5369cb4 to your computer and use it in GitHub Desktop.
Save sblack4/305025c3956341f8a5c85379b5369cb4 to your computer and use it in GitHub Desktop.
Comment all your terraform out in a variety of languages.

Comment out all your terraform code

vscode snippets for comments

other necessary files included. cmd+alt+b will select the line and make it a full comment block

awk

awk '{print "#" $0}' *.tf

perl

perl -pi -e's/^/#/' *.tf

# try this out
perl -e "print '#'x42 . \"\n#\n\" . '#'x42" | pbcopy

node

node -p 'fs = require("fs");fs.readdirSync(".").filter(x => x.endsWith(".tf")).forEach(y => {fs.readFile(y, "utf8", function (e,z) {if (e) {return console.log(e);};z.split("\n").forEach(l => console.log(`# ${l}`));});})'

vim

Yp - duplicate current line, leaving the cursor at the lower of the two
V - enter visual line mode
k - go up and select both lines
r# - replace every selected character with #. Leaves visual mode and leaves cursor at the upper line.
p - put the yanked line (the original) on the next line.
[
{
"key": "cmd+alt+b",
"command": "extension.multiCommand.execute",
"args": { "command": "multiCommand.createTextBlock" },
"when": "editorTextFocus && !editorReadonly"
}
]
"multiCommand.commands": [
{
"command": "multiCommand.createTextBlock",
"sequence": [
"cursorEnd",
"cursorHomeSelect",
{
"command": "editor.action.insertSnippet",
"args": {
"name": "Create a Text Block",
}
},
"cursorDown"
]
}
],
{
"Create a Text Block": {
"prefix": "tb",
"body": [
"##########################################",
"# ${TM_SELECTED_TEXT}",
"##########################################",
],
"description": "create a text block"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment