C# How To Run C# Code Inside Sublime Text

Hey folks, I want to share a tip. Sublime Text is my favorite for quick scripts, text editing and doing other scripting things or anything which doesn’t require a whole IDE. I love the speed too much and it is super-fast. In the process, I found that you can run C# scripts too, right from inside the Sublime Text, like you can run JavaScript. This is what I will brief you about:
Sometime back, I wrote on configuring Sublime Text for JavaScript too. Here’s the link, if you want to learn:
Ok, let’s start. The process is simple. You need to have an executable file, which Sublime Text will use to execute the scripts.
For C#, we will use scriptcs. Like NodeJS can run JavaScript, scriptcs runs C#. You can write and execute an Application with only one line of code.

Steps to configure Sublime Text for executing C# codes
Step 1: Install scriptcs

In order to install scriptcs, you need to have chocolatey. Chocolatey is a package manager for Windows.

You can install it in two ways:
  1. Using the command prompt (cmd.exe): Run the command, given below in the console:
    1. @powershell -NoProfile -ExecutionPolicy Bypass -Command “iex ((new-object net.webclient).DownloadString(‘https://chocolatey.org/install.ps1’))” && SET PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin
  2. Using Powershell : Run either of the following commands
    1. iex ((newobject net.webclient).DownloadString(‘https://chocolatey.org/install.ps1’))
    2. iwr https://chocolatey.org/install.ps1 -UseBasicParsing | iex  

    There’s a chance you will get an error while running the script due to a Powershell Execution policy. By default, it is set to “Restricted” to prevent the harmful scripts from running. You can check the current execution policy by running “Get-ExecutionPolicy” command in Powershell.

If you encounter this error, set the execution policy to “RemoteSigned” and run the installation command again. Use the command given below:
  1. Set-ExecutionPolicy RemoteSigned
 Make sure you start the Powershell console in Administrator mode, otherwise the change will not take place.



Read full article here on C# Corner:


Happy learning 🙂

How to configure Sublime-Text to Open HTML file in Chrome on build

Many times I use Sublime Text as my GoTo text editing tool for not so serious scripting and want it to html files in Google Chrome on build. Here I’m sharing the steps how I made it work. You first need to create a “Build System” called by Sublime Text in order to achieve this purpose. Build Systems are JSON files having extension name as “.sublime-build“. It allows you to run external programs from within the editor.

As the Sublime Text Unofficial Documentation –“Build systems let you run your files through external programs like make, tidy, interpreters, etc.”

Coming to the actual point of this post, to create a build system to run your HTML files in Google Chrome on build: follow the steps below:

I’m using Sublime Text 3 and running Windows 7 OS.

1. Start Sublime Text > Goto Tools > Build System > New Build System:

2. It will open a file named “untitled.sublime-build” looking like picture below:

3. Find “Google Chrome” Programs > Right click on  Properties > Copy the full path of the application, it will look like this:


YourUserName” is your user account name under which you’re working in Win 7 OS.

4. Modify the contents of new sublime build file as below and save as “Chrome.sublime-build”. By default it shows the build directory that should be:

“C:UsersYourUserNameAppDataRoamingSublime Text 3PackagesUser” 

If you see any other folder, please ensure and change it to the folder above otherwise Sublime Text will not be able to see and use this build system.

And Yes, don’t forget to escape the backslash in the path! (highlighted in violet in picture below)

5. Now as you have saved he build system as “Chrome.sublime-build” in Build Systems directory, it will now show up in “Build System”, select it:

You’re all done now. Just open any html file or write and save new file as html and press “CTRL+B” or Goto Tools>Build and it will open the HTML file in Google Chrome.

Thanks for reading! Hope you enjoyed this article.