Basics of Visual Studio Code

Basics of Visual Studio Code

Search for: Basics of Visual Studio Code

Introductory videos

Folder seems to be equivalent to a project in IDEs like ecliplse

Opened files will show up in the "opened editors"

A folder can contain any type of file unlike IDEs

You can access a command line terminal from the editor itself


reveal folder option

settings
.vscode
   settings.json

done through "configure tasks"
.vscode
   tasks.json

vscode homepage


Accidentally you may have 
  Right clicked on a folder
  turn off open editors

That will seem to take  off the folders from the view

//to undo
Right click on Explo... 
Choose open editors 
That will show folders again

//Strange

how to clone a git repo in vscode?

Search for: how to clone a git repo in vscode?

How do I unopen a folder in vscode?

Search for: How do I unopen a folder in vscode?

How to close or remove an open folder in vscode?

Search for: How to close or remove an open folder in vscode?

There are no active source control providers in vscode

Search for: There are no active source control providers in vscode

This seem to be related to work spaces!!!

what are vscode workspaces?

Search for: what are vscode workspaces?

vscode and git credential manager

Search for: vscode and git credential manager

Git Extension Pack Vscode

Search for: Git Extension Pack Vscode

How to customize command lines in vscode?

Search for: How to customize command lines in vscode?

A workspace is a collection of folders

You can open a folder in the context of a work space. In other words you can "add folder to a work space"

Or you can open a folder that is outside of any work space

You can open and close a work space

If you "add folder to a workspace" and there is no work space in place, it opens an untitled workspace

You can do a save as on a workspace

You can open a workspace later using the saved workspaces

A work space details is kept in a file with an extension of .workspace

Settings can be overridden at a) global level - user b) work space level c) folder level

Folders that are open without a work space are then by extension in the default or nameless work space

What I know so far!

My goal here is how to run an integrated terminal that has all the right paths set to run a node.js command. This means running a .bat or a .cmd file when the integrated command line opens. I also want to have the option to run a git command line in the same work space and want to have that option.

This is commonly referred to as "integrated terminal"

There appears to be complex semantics around this beast

Out of the box one can set this command line experience to be either the standard cmd.exe or a powershell. But not both (I think!)

There is an extension called "Shell Launcher" that will provide the ability to have multiple options such as a) node shell b) bash shell c) power shell etc.

There is something called a "Command Palette" in vscode where these shells are exposed to be kicked off.

I have briefly also installed "Start Any Shell" extension. But this appears to be for external shells and not the integrated kind.

I was not able to pass command line arguments to these shells that allows me to set the paths needed for say a node command line.

However I was able to directly set the command pointing to a .bat file that seem to have done the trick

I would like to play with the args explicitly to see if that works instead!


{
  "shellLauncher.shells.linux": [
    {
      "shell": "bash",
      "args": ["-l"],
      "label": "bash login shell"
    }
  ]
}

// A list of shell configurations for Windows
"shellLauncher.shells.windows": [
    {
        "shell": "C:\\satya\\i\\node\\nodevars.bat",
        "label": "Node Cmd Shell Launcher"
    }
]

The nodevars.bat is typically would have been invoked from the windows start menu as


C:\\Windows\\System32\\cmd.exe /k C:\\satya\\i\\node\\nodevars.bat

I wonder what the difference is by employing the shortcut I used! wonder if the same thing can be accomplished via args params.


// A list of shell configurations for Windows
  "shellLauncher.shells.windows": [
    {
      "shell": "C:\\Windows\\System32\\cmd.exe",
      "label": "cmd"
    },
    {
      "shell": "C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe",
      "label": "PowerShell"
    },
    {
      "shell": "C:\\Program Files\\Git\\bin\\bash.exe",
      "label": "Git bash"
    },
    {
      "shell": "C:\\Windows\\System32\\bash.exe",
      "label": "WSL Bash"
    }
  ]

See the description show up

Once it is picked, hopefully it shows at the top.


Menu/View/Command palette
Or
Ctrl+shift+p

For me the later keys are already intercepted by another program on my computer! I have to find a better combination!

how do i know where workspace file is located in vscode?

Search for: how do i know where workspace file is located in vscode?

Really nothing worked

Even the .bat or .cmd files as a target didn't work too well

So I just used the native without extensions

At least the native one opens up the command line at the right directly, which is half the battle

Then I created c:\satya\utils\set-node-env.cmd and set-git-env.cmd etc which I execute manually once.


@rem *******************************************
@rem * call to a batch file to setup node env variables
@rem * This batch file came with node installation
@rem * This is what node install sets up as "Node commandline"
@rem *
@rem * location: c:\satya\data\codebase\utils
@rem * This location is added to the system path
@rem * in the environmental variables.
@rem *******************************************
c:\satya\i\node\nodevars.bat

What a waste of time!!! with these terminal extensions :(

What is Gitlens?

Search for: What is Gitlens?


workspace .workspace in a diff directory
many source folders opened underneath
  folder1
  folder2
     .git
  folder3

It seem to work. But I am getting odd results. Any thing I want to git must be under "folder2". How is the workspace and git source control related in git. I need to get a better handle on this

GitHub Vscode workspaces

Search for: GitHub Vscode workspaces

Git repos and vscode workspaces

Search for: Git repos and vscode workspaces

How do I initialize a workspace in vscode with github repo?

Search for: How do I initialize a workspace in vscode with github repo?

How do I clone a repo with gitlens in vscode?

Search for: How do I clone a repo with gitlens in vscode?

How to unhide .git directory in vscode?

Search for: How to unhide .git directory in vscode?


"files.exclude": {
    "**/.git": true,
    "**/.svn": true,
    "**/.hg": true,
    "**/.DS_Store": true
}

"files.exclude": {
     "**/.git": false
}

It will not work if you do this in workspace settings...fyi


[core]
   repositoryformatversion = 0
   filemode = false
   bare = false
   logallrefupdates = true
   symlinks = false
   ignorecase = true
[remote "origin"]
   url = https://github.com/pjiwe/Big-Data-Collab
   fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
   remote = origin
   merge = refs/heads/master

Go to command palette (ctrl-shift-p)

type: git

choose: git: clone

You will be prompted for repo URL

you will be prompted for a local directory

Vscode will ask you in the end to add that folder to the current workspace if you choose.

This is a much better option than doing a git init on a folder and starting from there


workspace .workspace in a diff directory
many source folders opened underneath
  //repo 1 root folder
  folder1
     .git

  //repo 2 root folder
  folder2
     .git

  //some untracked root folder
  folder3

1. It uses the name of the repo on the server as a directory name. Let me call it "abc-repo"

2. It then asks a root directory name to place that folder under. Exmaple "some-root"

3. The created repo directory on local will be "some-root\abc-repo"

4. Once created you can change the directory names if you like.

5. If you change directory names VSCode will loose track of the previous folder that was attached to the workspace. You will then need to remove the old folder and attach the new folder.


c:\repos -- root directory
      \some-code1-repo\other code directories
      \some-code2-repo\other code directories

why does vscode shows only one opened file in the top tab

Search for: why does vscode shows only one opened file in the top tab

Here is some discussion on this preview vs you actually want to open that file


dbl click to keep it open
single click to preview

with single click sometimes files stick around and sometimes not

How do I navigate to a folder quickly in vscode?

Search for: How do I navigate to a folder quickly in vscode?

  1. setttings
  2. workbench
  3. Appearance
  1. ctrl-shift-p, preferences, color theme
  2. Or file, preferences, settings, "search for color theme"
  1. If there is nothing open it is called an empty folder or empty window state. Global settings apply.
  2. If you open "one folder" the folder is expected to be the workspace and configuration can be specialized for that folder workspace.
  3. :) Not sure what happens if you add an additional folder. Experiment and see.
  4. Any of these default work spaces can then be explicitly saved as a "Workspace" where you can attach multiple folders and manage that work space independently.
  1. See at the bottom of the file menu
  2. You have an option to close the current workspace.
  1. Close the current work space
  2. Then do a save as work space as your new work space
  3. Then add files, folders, repos, to this work space
  1. I have downloaded and installed github desktop
  2. It seemed to walk me through it.
  1. Install the ubiquitous MS python extension
  2. Go to command: Ctrl-shift-p
  3. Search for "Preferences: work space settings"
  4. Then there search for python.analysis.typeCheckingMode
  5. Set it to "strict"
  1. 1. Having multiple python installations
  2. 2. Multiple projects seem to throw off the selected interpreter
  3. 3. I removed from path one of the pythons
  4. 4. Didn't work
  5. 5. I deleted from hard drive that python release
  6. 6. It complained a few times about select interpreter crap
  7. 7. Somehow after multiple tries of selecting the interpreter it switched to the ONLY version available
  8. 8. That took only a few hours of debugging!