VSCode Config

2 minute read

Description:

So I have been using Cherrytree for a long time, but recently wanted to try out VSCode. Here is where I will keep my VSCode Settings over time. I exported all notes to a directory. Then used powershell to bulk rename all .txt to .md - see here

Keyboard shortcuts

  • Ctrl+Shift+p - Brings up search menu

Basic

  • shift+alt+f - format code (best feature in vscode!!)
  • shift+alt+up/down - Copy line
  • ctrl+end - go to end of file/ ctrl+home - go to beginning of file
  • alt+z - toggle line wrap
  • ctrl+x - No selection / cut line - same for copy and ctrl+c
  • Ctrl+Shift+v - In the editor, this allows you see your markdown in another tab

Cursors

  • Ctrl+Alt+up/down - Insert cursor above/below
  • shift+alt+i - Insert cursor at end of each line selected
  • Alt+Click - Add new cursor

Find / Replace

  • Ctrl+Shift+f - This searches all files. Just remember to put ./_notes in the includes if you want to search by folder
  • Ctrl+Shift+h - Same but replace

Extensions (as of 2019-06):

  • Linux Themes for VS Code
    • Preferred theme - ‘Monokai Dimmed’
  • Markdown All in one
    • So that you can use shortcuts to like Ctrl+B to bold something
  • Markdown PDF
    • Print PDFs from .md files
  • Paste Image
    • Allows you to paste from clipboard using Ctrl+Alt+V
  • Powershell
    • Auto format code using Ctrl+Alt+F
    • Auto linting
  • Puppet
    • Auto linting
  • vscode-fileheader
    • Press Ctrl+Alt+i to insert a header to a file
  • vscode-icons
    • Preferred icon theme
  • Insert DateString
    • Adds date by Ctrl+Shift+i and full date by Ctrl+Shift+Alt+i

Extensions - Config

  • Configure vscode-fileheader
    "fileheader.tpl": "---\r\n@Author: {author}\r\n@Date: {createTime}\r\n@Last Modified by: {lastModifiedBy}\r\n@Last Modified time: {updateTime}\r\n---\r\n\r\n",
    "fileheader.LastModifiedBy": "Gerry Williams",
    "fileheader.Author": "Gerry Williams",
    

Now, when you press Ctrl+Alt+i you get the following at the top of your file:

---
@Author: Gerry Williams
@Date: 2019-06-03 13:26:12
@Last Modified by: Gerry Williams
@Last Modified time: 2019-06-03 13:26:12
---

settings.json (User/Workspace)

VS Code provides two different scopes for settings:

  • User Settings - Settings that apply globally to any instance of VS Code you open.
  • Workspace Settings - Settings stored inside your workspace and only apply when the workspace is opened.
  • Note: Workspace settings override user settings.
User:
// Place your settings in this file to overwrite the default settings
{
    "files.hotExit": "off",
}

Workspace:

// Place your settings in this file to overwrite the default settings
{
"editor.acceptSuggestionOnEnter": "off",
    "editor.autoClosingBrackets": "never",
    "editor.codeLens": false,
    "editor.cursorStyle": "line",
    "editor.foldingStrategy": "indentation",
    "explorer.confirmDelete": false,
    "explorer.confirmDragAndDrop": false,
    "files.autoSave": "afterDelay",
    "files.autoSaveDelay": 2000,
    "files.eol": "\n",
    "git.autofetch": true,
    "git.enableSmartCommit": true,
    "git.fetchOnPull": true,
    "powershell.codeFormatting.preset": "Allman",
    "terminal.integrated.cursorStyle": "underline",
    "workbench.colorTheme": "Monokai Dimmed",
    "workbench.iconTheme": "vscode-icons",
    "fileheader.tpl": "---\r\n@Author: {author}\r\n@Date: {createTime}\r\n@Last Modified by: {lastModifiedBy}\r\n@Last Modified time: {updateTime}\r\n---\r\n\r\n",
    "fileheader.LastModifiedBy": "Gerry Williams",
    "fileheader.Author": "Gerry Williams",
    "breadcrumbs.enabled": false,
    "workbench.sideBar.location": "left",
    "window.zoomLevel": 0,
    "[shellscript]": {
        "editor.defaultFormatter": "foxundermoon.shell-format"
    },
    "python.pythonPath": "c:\\_gwill\\google\\scripts\\python\\python36\\python",
    "python.linting.pylintEnabled": true,
    "python.linting.pep8Enabled": false,
    "python.linting.enabled": true,
    "python.formatting.provider": "yapf",
    "explorer.autoReveal": false,
    "insertDateString.format": "YYYY-MM-DDThh:mm:ssZZZ",
    "insertDateString.formatDate": "YYYY-MM-DD",
}

keybindings.json

Preferences: Open Keyboard Shortcuts File (json)

// Place your key bindings in this file to overwrite the defaults
// Place your key bindings in this file to overwrite the defaults
[
    {
        "key": "ctrl+n",
        "command": "explorer.newFile",
        "when": "explorerViewletFocus"
    },
    {
        "key": "ctrl+shift+i",
        "command": "-workbench.action.toggleDevTools",
        "when": "isDevelopment"
    },
    {
        "key": "ctrl+shift+i",
        "command": "-insertDateString.insertDateTime",
        "when": "editorTextFocus"
    },
    {
        "key": "ctrl+shift+i",
        "command": "insertDateString.insertDate"
    },
]

Dont forget - Create VSCode PS profile: Microsoft.VSCode_profile.ps1 in C:\users\username\Documents\WindowsPowershell