Visual Studio Tips

Package Management Tip – lightning speed workflow!

Posted by matteskolin on

I really appreciate how VSCode makes it possible to do things faster, compared to Visual Studio proper.

Managing Nuget packages for me in Visual Studio Proper always involved opening up the Nuget GUI, searching for the package, selecting a version, clicking check boxes to add the package to specific projects, and then clicking through a bunch of confirmation prompts before finally installing the package.

In VSCode, a more streamlined way of doing this is to add the PackageReference directly to the project .csproj file. Just add a PackageReference element inside an ItemGroup with the Package Name and version.

You can do this in Proper as well, but it is more difficult to edit the project file, as the entire project may need to be unloaded and loaded, which can be slow.

<ItemGroup>
<PackageReference Include="Polly" Version="7.2.1"/>
</ItemGroup>

Save the Project File and run the dotnet restore command. The project will be built and the package assemblies will be copied to the project output folder.

dotnet restore

After editing the .csproj file I use Cntrl + ~ to jump down to the VSCode terminal to run the dotnet restore command. Managing packages this way is fast and easy.

Visual Studio Tips

Vim Took over VSCode Keybindings

Posted by matteskolin on

I enjoy using vim in VSCode and VS Proper, however, getting all the keyboard commands to meld between vim and the IDE can be a challenge. I was working the other day trying to do something as simple as find text in the current open file. Cntl + F for find right? Wrong, because in vim Cntl + F is advance forward through the file.

I could use a vim command for find such as ‘/’, but I am so used to Cntl + F, that I wanted to use this instead.

Actually, it turns out for me, most of the vim control key bindings are not important for me, but the normal control bindings are quite critical (copy and paste, select all, find, etc)

In VSCode, there is a setting for Vim to to tell it what keys not to handle. Adding this below to my settings.json greatly improved my workflow in VSCode, while allowing me to continue to use vim.

    "vim.handleKeys":{
      "<C-k>":false,
      "<C-a>":false,
      "<C-t>":false,
      "<C-f>":false,
      "<C-c>":false,
      "<C-v>":false
    },

For more details, see Vim extension documentation.

https://marketplace.visualstudio.com/items?itemName=vscodevim.vim