I am sure many of you might have wished to have a portable C# compiler + editor combo which you can carry with you anywhere. Sometime ago, I had the same need. Unfortunately there exists no version of ‘Visual Studio’ which can be termed ‘light weight/portable’. Hence, I started researching for ways to create a portable compiler + editor setup which allowed me to write and run C# code without installing Visual Studio.
I was pleasantly surprised to know that my good old friend Notepad++ , with the help of CS-Script plug-in , allowed me to do what I wanted. Before I take you through the process of setting up Notepad++ and CS-Script for C# coding, I would like to thank everyone involved in making of these two piece of software, wholeheartedly.
First, download the zipped version of Notepad++ (ignore if you already have it). Unzip it to a folder. Then , from the main menu, select Plugins -> Plugin Manager -> CS-Script (C# autocompletion)
Click install, and this should install the CS-Script plug-in.
Once you have the plug-in installed, you might want to create a keyboard shortcut to launch your C# programs. So, go to Settings -> Shortcut Mapper ... -> Plugins Command
and select an appropriate key combination. In the below screen shot I have selected ‘ALT + 5’. Make sure the shortcut is unique and not already in use.
Now its time to try out your setup. But before that, I would recommend using a dark theme for C# editing for that ‘cool nerd’ effect. Go to Settings -> Style Configurator
and select a theme of your choice. I have selected ‘Black board’ theme in the below screen shot.
Now we are almost done. Create a new file in Notepad++ . Then from ‘Language’ menu select C -> C#
. Write your code and hit ‘ALT + 5’. If there are no errors , your code should run. You should be able to see the ‘Output Panel’ at the bottom of your screen. If not, goto Plugins -> CS-Script -> Output Panel
. In the ‘Output Panel’, if ‘Intercept StdOut’ is checked, compilation errors will be shown. A very handy feature.
And yes, I almost missed the part about autocompletion. You definitely will appreciate the (somewhat limited) autocompletion support which the CS-Script plugin offers. Please do not expect this to be anywhere near what Visual Studio or other paid tools offer, but I think its a really useful. The size of the whole setup is less than 8 MB when zipped, which in my opinion is pretty awesome. I have used this setup to write many small programs in C# and have fun.
Before, I end this article, I would also like to mention Linqpad , which is wonderful tool for c# scripting and doing other wonderful things with databases. at the time of writing this article, autocompletion was not offered with free version of linqpad. however, using notepad++ has its own advantages. very soon, i am planning to write about using notepad++ as query tool for ms sql, so stay tuned. please feel free to share your experiences or suggestions by leaving comments below !