Logo

VSCode

As much as I like VSCode there are a few customizations that I always have to perform when installing it.

Keybindings

I got somewhat familiar with emacs keybindings so I set up the following:

Keybinding Command
ctrl-x 3 View: Move Editor into Right Group
ctrl-x 2 View: Move Editor into Group Below
ctrl-x 1 Join All Editor Groups
command-shift-O File: Open Workspace From File

Themes

I have the Dracula theme for VSCode, iTerm2, etc.

Script to Create/Update a Workspace

I put all of my workspace files in a separate directory. If I'm in a new directory (in a terminal) and want to create or add to a workspace, then I invoke the following script which is aliased to "workspace". It simply takes the current directory that I'm in and appends it to the given workspace name. Ex: workspace lambdas.

#!/path/to/python3.10
"""Create or add to a VS code workspace."""

import json
import os
import sys

PARENT_DIR = "/Users/me/vscode-workspaces"
WORKSPACE_FILE = "{}/{}.code-workspace".format(PARENT_DIR, sys.argv[1])


def add_path_to_workspace():
    with open(WORKSPACE_FILE, "r") as workspace_file:
        workspace = json.load(workspace_file)
        workspace["folders"].append({"path": os.getcwd()})
        contents = json.dumps(workspace, indent=2)
    with open(WORKSPACE_FILE, "w") as workspace_file:
        workspace_file.write(contents)


def create_new_workspace():
    workspace = {"folders": [{"path": os.getcwd()}], "settings": {}}
    contents = json.dumps(workspace, indent=2)
    with open(WORKSPACE_FILE, "w") as workspace_file:
        workspace_file.write(contents)


def main():
    if os.path.isfile(WORKSPACE_FILE):
        print("Adding path to existing {}".format(WORKSPACE_FILE))
        add_path_to_workspace()
    else:
        print("Creating {}".format(WORKSPACE_FILE))
        create_new_workspace()


if __name__ == "__main__":
    main()