In August, at the end of a .NET talk I gave, Ben came
up to me saying I should use Notepad2
instead of Notepad. At that time, I rejected his suggestion.
Here is why. In most of my talks I use either VS.NET (for
.NET talks) or IntelliJ IDEA (for
Java talks)
for about 95% of the time (I am that crazy guy who likes to codes 85 minutes in a
90 minutes talk).
The only time I use notepad is if I want to jot down a quick reference for the audience.
Notepad
works great for that and I saw (and still see) no reason to use anything more than
that for that
purpose. I am not a fan of picking a tool for the sake of picking another tool.
Well, today, I want to thank Ben for making that suggestion. I will still use good
old notepad for
simple things?it works. But, I took Ben?s advice for a talk I gave this afternoon
at the NFJS event
in Calgary.
One of my talks this evening was "Groovy
for Java Programmers." I have a number of demos in
that talk. I don?t like to use the groovyconsole?it does not quite feel right, it
prints the result in the
console window in the back, it puts some not-so-useful-during-the-demo information
on the
bottom window, etc. One think I do like in it is that you press Ctrl+R and it runs
your groovy
code. It got me thinking, if I can do that from within notepad that will be cool?then,
I don?t have to
switch to the command window to type the script in order to run. But, I don?t think
the good old
notepad can help me with that (IDEA has a plugin for groovy but I have not yet
upgraded to 5.0,
besides, I want to work with the minimum on this talk).
So, this afternoon I downloaded Notepad2 and
did a few silly things to get this working! The one
feature that made this possible is the ability to run a script from within Notepad2.
But, I can't
use that feature directly as the console window would not stay up after the script
executes.
Here is what I did to keep the console window up after the script runs:
Wrote a simple script (shown below) and saved it into a file named ?runGroovy.bat?
in the
C:\Windows\System32 directory:
#
runGroovy.bat
echo off
cls
call groovy %1
pause
Then, in Windows Explorer, I right clicked on a sample Example.groovy file that I
had created,
clicked on Properties, in the dialog that popped up, clicked on "Change?" button next
to "Opens
with", and selected the runGroovy.bat as the program to start with.
In Notepad2, I set the Settings | Save Before Running Tools. Within Notepad2,
I wrote a simple
Groovy program as shown below and saved it into c:\examples\Example.groovy file.
Now when I hit Ctrl + L, the following came up:
Now, I make a simple change to the program as shown below:
Then I hit the Ctrl + L again to see this:
When I hit the return key, a console window popped up with the output of the program.
So, you can write code in Notepad2, hit Ctrl + L, and right there run your Groovy
code.
It made for a very convenient demo this afternoon in front of a Groovier audience.
Now, that was pretty simple, unless you can show me something simpler on Windows.