VSCode Notes

Fine, you win world.

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 <extension name>

For example:

code --install-extension vscodevim.vim

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": "Launch",
            "type": "go",
            "request": "launch",
            "mode": "debug",
            "program": "${workspaceRoot}",
            "env": {},
            "args": ["cobraapp", "-t", "/home/ubuntu/targets.txt", "-a", "/home/ubuntu/stuff.txt", "-i", "/home/ubuntu/things.txt"],
            "port": 9090,
            "host": "127.0.0.1"
        }
    ]
}

Resources:
https://github.com/golang/vscode-go/issues/136 - nearly complete example
https://stackoverflow.com/questions/57290306/debug-file-other-than-main-go-in-vs-code - complete example

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": "Launch",
            "type": "go",
            "request": "launch",
            "mode": "debug",
            "program": "${workspaceRoot}",
            "env": {},
            "args": ["cobraapp", "-t", "/home/ubuntu/targets.txt", "-a", "/home/ubuntu/stuff.txt", "-i", "/home/ubuntu/things.txt"],
            "port": 9090,
            "dlvLoadConfig": {
                "followPointers": true,
                "maxVariableRecurse": 1,
                "maxStringLen": 400,
                "maxArrayValues": 80,
                "maxStructFields": -1
            },
            "host": "127.0.0.1"
        }
    ]
}

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