Evan Harmon - Memex

VS Code

img Visual Studio Code, also commonly referred to as Vs code, is a source-code editor made by Microsoft with the Electron Framework, for Windows, Linux and macOS. Features include support for debugging, syntax highlighting, intelligent code completion, snippets, code refactoring, and embedded Git. Users can change the theme, keyboard shortcuts, preferences, and install extensions that add functionality.
wikipedia:: Visual Studio Code

Setup & Customizations

Extensions

Tasks

Git

  • https://code.visualstudio.com/docs/editor/versioncontrol
  • Commit
    • You can type a commit message above the changes and press Ctrl+Enter (macOS: ⌘+Enter) to commit them. If there are any staged changes, only those will be committed, otherwise all changes will be committed.
  • Fetch
    • git.autofetch should be set to false by default for some reason. I set it too true. It automatically fetches from upstream repos periodically and maybe also before ay pulls or pushes? - But I couldn't get it working. Maybe it just does origin not upstream
  • Push, Pull, and Sync
    • Given that your repository is connected to some remote and that your checked out branch has an upstream link to a branch in that remote, VS Code offers you useful actions to push, pull and sync that branch (the latter will run a pull command followed by a push command). You can find these actions in the More Actions ... menu.
  • Status Bar Actions
    • There is a Synchronize Changes action in the Status Bar, next to the branch indicator, when the current checked out branch has an upstream branch configured. Synchronize Changes will pull remote changes down to your local repository and then push local commits to the upstream branch.
    • If there is no upstream branch configured and the Git repository has remotes set up, the Publish action is enabled. This will let you publish the current branch to a remote.
  • Diffs
    • Compare whole folders or projects - I don't think VS Code can do it but Git Lens can
    • You can diff any two files by first right clicking on a file in the Explorer or OPEN EDITORS list and selecting Select for Compare and then right-click on the second file to compare with and select Compare with 'file_name_you_chose'. Alternatively from the keyboard hit ⇧⌘P and select File: Compare Active File With and you will be presented with a list of recent files.
  • Visual Indicators
    • A red triangle indicates where lines have been deleted
    • A green bar indicates new added lines
    • A blue bar indicates modified lines
  • Merge Conflicts
    • Differences are highlighted and there are inline actions to accept either or both changes. Once the conflicts are resolved, stage the conflicting file so you can commit those changes.
  • Git output window
    • You can always peek under the hood to see the Git commands we are using. This is helpful if something strange is happening or if you are just curious. :) To open the Git output window, run View > Output and select Git from the drop-down list.
  • GitHub Pull Request Extension v

How-to's & Tips

  • Disable showing release notes every month
  • Move sidebar right since then text will always be aligned left to the same spot instead of jarringly bouncing in and out whenever you enable/disable the sidebar. And when on right the sidebar hovers over the text instead of moving any of the text anywhere
  • Don't bother with terminal code editors like nano and vim anymore. Just open text files with code someFile or to force open in a new window do code -n someFile
  • Find and replace in all files in a folder
  • You can wrap lines with a tag with emmet comand via command pallette - wrap with abbreviation and just type p or h2 or whatever
  • Single clicking on a file in the sidebar opens the file in preview mode (it doesn't stay open when you click on another file). Double clicking on a file will open it and keep it open. Files in preview mode are in italics.
  • Create Open in VS Code Quick Action and attach hotkey to it

Code Folding

  • Indent arbitrary code and then you can fold on the header of those indented lines, e.g. multiline #comments
    • This has the advantage that you don't have to change the actual text
  • #region - #endregion makes the code between foldable

Refactoring

  • Rename Symbol - F2
    • Smartly renames variables, function names, etc. I think works across files
  • Refactor - Shift-Ctrl-R
  • Go to implementation, reference, etc. - F12, Shift F12, etc.

Features

Dev container

Sources

Remember - if you select some text, and then hit a symbol like " or { it will guess that you want to wrap that selection with that symbol!

VS Code
Interactive graph
On this page
VS Code
Setup & Customizations
VS Code Hotkeys
Extensions
Tasks
Git
How-to's & Tips
Code Folding
Refactoring
Features
Dev container
Sources
This site is no longer active. If you are the owner of the site, please update your subscription here.