Level Up - Dev: How to write a Ruby program in Windows using Notepad++
Not all programs need to have a fancy IDE. If there’s a quick script that you want to run or try, then using a simplier Notepad++ can easily get the job done. And, it already includes syntax highlighting for Ruby.
Prerequisites:
Let’s get started:
- Open Notepad++
-
Add custom menu option to run the Ruby code:
- On the menu bar, click Run->”Run…”
- On the popup enter the command:
cmd /K ruby "$(FULL_CURRENT_PATH)"
- Click “Save…”
- Enter a name for the custom run command, like “Run Ruby Program”
- Click “OK”
-
Time to test. Add the following program to a new file:
def factorial(n) if n == 1 1 else n * factorial(n - 1) end end puts factorial(5)
- Save the file, then click Run->”Run Ruby Program”. You should see the output of the Ruby program in a command prompt.
Congrats, you can now be more productive with the great Notepad++!
Now a quick word from a tech company who helps support me and this site: