Quite often, in my day-to-day workflow, I want to wrap up some code section in a well-known code snippet. I hate these moments. Usually, you want to cut and paste some code, and after that formatting goes wrong and all of that 😱. So…
I would like to share with you extension for vscode that I wrote for personal use. (marketplace.visualstudio.com/surround-with-csharp) The goal of this extension is to provide the capability to wrap up selected text in a C# code snippet.
This extension supports different concepts to trigger functionally to surround your code.
Source code: https://github.com/NikiforovAll/surround-with-csharp
You can just simply hit
CTRL + SPACE and if you have some code selected, you will get completion items that you can choose from by using arrow keys:
If your favorite command-pallette. You can invoke command “C#: Surround With” (or
CTRL+SHIFT+S, CTRL+SHIFT+S) and you will be prompted for a code snippet.
Here is a list of keybindings provided by extension for quicker access to commands to use a particular snippet. You can assign your own keybindings if you want to.
Some commands are not bound at all. So if you are “I want to wrap all my code in regions” kind of guy, you can go to “Keyboard Shortcuts” and find all subcommands. Usually, the name starts with “surround.with”.
Hope you find this useful, have fun! 🎉