VSCode Notes

Future note to self regarding VSCode/VSCodium

I use VSCode on my Windows work machine and VSCodium on my personal Linux machine.

Addons

Keybindings

keybindings.json

[
    { // create a link to remote git (e.g. Github) for the current line and copy that to clipboard
        "key": "ctrl+c l",
        "command": "gitlens.copyRemoteFileUrlToClipboard"
    },
    { // terminal copy text
        "key": "ctrl+c",
        "command": "workbench.action.terminal.copySelection",
        "when": "terminalFocus"
    },
    { // terminal paste text
        "key": "ctrl+v",
        "command": "workbench.action.terminal.paste",
        "when": "terminalFocus"
    },
    { // terminal interrupt aka ctrl+c
        "key": "ctrl+shift+c",
        "command": "workbench.action.terminal.sendSequence",
        "args": {
          "text": "\u0003"
        },
        "when": "terminalFocus"
    },
    { // toggle terminal fullscreen/partial screen
        "key": "alt+`",
        "command": "workbench.action.toggleMaximizedPanel"
    },
    { // jump back in the file/line navigation stack
        "key": "alt+left", // Windows default, overriden on Linux
        "command": "workbench.action.navigateBack"
    },
    { // jump forward in the file/line navigation stack
        "key": "alt+right", // Windows default, overriden on Linux
        "command": "workbench.action.navigateForward"
    }
]

To get alt+` to work on Gnome I had to go into Gnome preferences -> Keyboard -> Keyboard Shortcuts -> Navigation and alter the ‘Switch Windows of an Application’ item. It says super + ` by default but is in reality also aliased to alt+` !! Edit the shortcut and make it just super+` - this removes the alt+` shortcut.

Windows

On Windows I also run WSL2 (Windows Subsystem for Linux) and use that for any VSCode terminal stuff. I found that it would eventually consume all available RAM! To limit RAM usage I put this in .wslconfig file:

[wsl2]
memory=3GB

Podman

Using podman from within WSL2 environment needs some setup. You have a ‘podman machine’ which is a WSL2 instance where containers run. There are two main issues to overcome:

Sockets: you can either manually bind mount that socket to the shared /mnt/wsl path or, since Podman v4.7.0, a podman socket is automatically made available under /mnt/wsl/podman-sockets/[machine name]/.

Once the socket is in place, add this to your WSL instance’s .bashrc:

export CONTAINER_HOST=unix:/mnt/wsl/podman.sock  
export DOCKER_HOST=$CONTAINER_HOST

Startup: install Podman Desktop and it will take care of starting the podman machine at boot time.

Volumes: /mnt/wsl is a shared path between your WSL instances and the podman machine, so just make sure to put any files under there that you need to mount into your containers.