Skip Navigation LinksHome > View Post

Your first Visual Notepad application

This happens to me lots. I'm discussing a piece of code with my colleagues and I say "I'm sure you can use A to do B" and he says "No, A can't do B, it can only do C". Naturally, I retort "No way!", so we settle the argument the only fair way: with some test code. And this is where it used to get fiddlesome.

One of us fires up Visual Studio 2005 and creates a new Console Application project, including the million or so additional bits and pieces that VS 2005 creates. All this just to test one or two lines of code.

The hacks at microsoft use a different tool for this sort of thing, and they've nicknamed it Visual Notepad. In reality, it's the everyday "common or garden" notepad that we all know and love.

I discovered this 'new tool' a couple of months back and I love it now - plus it makes rewards me with a sense of hardcore achievement to have to work without intellisense occasionally.

Want to join in the fun? It's easy - why not try it out by following the steps below.

1. Open Notepad (I press the Windows Key and 'R' to bring up the Run dialog. Then type 'Notepad' and hit enter. Bingo).

2. Type in this code. Don't paste it - the practice will do you good.

using System;

public class MyFirstVisualNotepadApplication
{
    // all apps have to have a void main entry method
    public static void Main()
    {
        Console.WriteLine("Wow, I did it!");
    }
}

3. Save your file somewhere accessible with a .cs extension (e.g. "C:\temp\test.cs").

4. Open a Visual Studio 2005 Command Line* and navigate to the folder in which you saved your file (e.g. "cd temp").

5. Type "csc temp.cs" or whatever you called your file.

6. If you followed the instructions precisely, your compilation should have completed without any errors. Now type "test.exe" (or whatever you called your file)...

Congratulations, you did it!

* I use the VS2005 command line all the time so to make it easier, I setup a batch file to configure everything for me. If you want to do the same, open notepad and paste this text into the first line:

%comspec% /k ""C:\Program Files\Microsoft Visual Studio 8\VC\vcvarsall.bat"" x86

Save the file as "C:\WINDOWS\System32\netcmd.bat" and now you can access the VS2005 command line by simply typing "netcmd" into the Run dialog (Windows+R) at any time:)

I realise this post contains nothing new, but using Notepad in this way has revolutionised the way I play with .NET. If you're not already doing so, I suggest you try it and hope you find it as refreshing as I have :)

PS - I actually use the amazing Notepad2 but normal Notepad is fine.

Update: I've since posted another article that can take your Visual Notepad to the next level.

Tags: .NET

 
Josh Post By Josh Twist
7:05 AM
09 Jan 2006

» Next Post: Web 2.0 on the radio
« Previous Post: CLR Inside Out

Comments are closed for this post.

Posted by Nick Parker @ 20 Mar 2006 6:25 AM
Josh,

I might recommend setting the AutoRun key in the registry for the command processor as an alternative. A link to where I talk about it:

http://developernotes.com/archive/2005/09/10/729.aspx

-Nick

Posted by Brad @ 14 Apr 2006 11:44 PM
It sounds like you would love slick run (http://www.bayden.com/SlickRun).

Configure and run these type of commands with a couple keystrokes. Allows for dynamic entry of additional parameters.
So for example, if I want to compare 2 files, I hit Window/A c (for my compare command that's set to launch a compare utility). I'm prompted for the first path, then the second, then I see the results.
Even easier; I paste both paths into a "jot" window (Windows/J) that's also part of the tool before running so I can easily copy the paths from there.

© 2005 - 2014 Josh Twist - All Rights Reserved.