Symbols to keep in mind

⌘ is the command key aka the windows key ⇧ is the shift key ⌃ is the control key ⌥ is the alt key

Switch between windows

On Mac: ⌘ tab number

For example: ⌘2

Resource: https://zellwk.com/blog/useful-vscode-keyboard-shortcuts/

Markdown

This extension is great, install it: https://marketplace.visualstudio.com/items?itemName=yzhang.markdown-all-in-one&ssr=false#overview

Show preview of MD file

On Mac: ⌘⇧V

On Windows and Linux: Ctrl Shift V

Extensions via command line

List existing extensions:

code --list-extensions

Install an extension:

code --install-extension $EXT_NAME

For example:

code --install-extension redhat.ansible
code --install-extension amazonwebservices.aws-toolkit-vscode
code --install-extension vscodevim.vim

Uninstall extension:

code --uninstall-extension ms-vscode.csharp

Resource: https://stackoverflow.com/questions/34286515/how-to-install-visual-studio-code-extensions-from-command-line

Interacting with code on remote systems

Install the remote extension pack

code --install-extension ms-vscode-remote.vscode-remote-extensionpack

You may need to close VsCode for the installation process for the extension to complete.

To connect to a remote system:

  1. Click the Remote Explorer icon in the lefthand menu
  2. Click the + next to SSH TARGETS
  3. Type in the ssh command to connect to your remote system
  4. Specify the config file you want to hold the SSH connection information
  5. Right click the new target to connect to the system

At this point you should be able to interact with files on the filesystem.

Resource: https://code.visualstudio.com/docs/remote/remote-overview

Trigger word wrapping

On Mac: ⌥Z

On Windows and Linux: Alt Z

Resource: https://stackoverflow.com/questions/31025502/how-can-i-switch-word-wrap-on-and-off-in-visual-studio-code

Terminal

Open/Close

On Mac: ⌃`

Create new

On Mac: ⌃⇧`

Split window

On Mac: ⌘\

Resource: https://code.visualstudio.com/docs/editor/integrated-terminal

Switch between terminals

On Mac: ⌘p

Type in term <number of terminal window

For example, to switch to terminal window 1:

term 1

Open extensions menu

On Mac: ⌘⇧X

Resource: https://code.visualstudio.com/docs/containers/overview

Debug cobra app

Create launch.json:

{
    "version": "0.2.0",
    "configurations": [
    {
      "name": "Debug caldera",
      "type": "go",
      "request": "launch",
      "mode": "debug",
      "program": "${workspaceRoot}",
      "args": ["--debug",
      "-t",
      "/home/ubuntu/targets.txt",
      "-a",
      "/home/ubuntu/stuff.txt",
      SomeCobraApp],
   },
  ]
}

Resources:

Show larger variables

In the event you have large variables that you want to view the full values of, modify the previous example like so:

{
    "version": "0.2.0",
    "configurations": [
    {
      "name": "Debug caldera",
      "type": "go",
      "request": "launch",
      "mode": "debug",
      "program": "${workspaceRoot}",
      "args": ["--debug",
      "-t",
      "/home/ubuntu/targets.txt",
      "-a",
      "/home/ubuntu/stuff.txt",
      SomeCobraApp],
   "dlvLoadConfig": {
     "followPointers": true,
     "maxVariableRecurse": 1,
     "maxStringLen": 400,
     "maxArrayValues": 80,
     "maxStructFields": -1
      },
   },
  ]
}

Resource: https://stackoverflow.com/questions/59756331/how-to-show-the-entire-value-in-vscode-debug-mode

Set go vars for debugging

{
  "go.gopath": "/Users/macuser/.gvm/pkgsets/go1.18.2/global",
  "go.goroot": "/Users/macuser/.gvm/gos/go1.18.2",
  "go.toolsEnvVars": {
    "GO111MODULE": "on",
    "GOARCH": "arm64"
  }
}

Fix golang package install

If you’re unable to install packages through the UI, try running this command:

rm "$(go env GOENV)"

Resource: https://github.com/golang/vscode-go/issues/2012

Run multiple actions with launch.json

{
  "version": "0.2.0",
  "configurations": [
    {
      "type": "go",
      "request": "launch",
      "name": "Deploy",
      "mode": "debug",
      "program": "${workspaceRoot}",
      "args": ["run", "-n", "thing"],
      "host": "127.0.0.1",
      "env": {
        "AWS_DEFAULT_REGION": "us-west-1",
        "AWS_PROFILE": "myaccount"
      }
    },
    {
      "type": "go",
      "request": "launch",
      "name": "Apply",
      "mode": "debug",
      "program": "${workspaceRoot}",
      "args": ["run", "-a", "anotherthing"],
      "host": "127.0.0.1",
      "env": {
        "AWS_DEFAULT_REGION": "us-west-1",
        "AWS_PROFILE": "myaccount"
      }
    },
    {
      "type": "go",
      "request": "launch",
      "name": "Destroy",
      "mode": "debug",
      "program": "${workspaceRoot}",
      "args": ["destroy", "-a", "onemorething"],
      "host": "127.0.0.1",
      "env": {
        "AWS_DEFAULT_REGION": "us-west-1",
        "AWS_PROFILE": "myaccount"
      }
    }
  ],
  "compounds": [
    {
      "name": "New Deploy -> Apply -> Destroy",
      "configurations": ["Deploy", "Apply", "Destroy"],
      "stopAll": true
    }
  ]
}

Resource: