From the Notepad++ menu, click on Settings => Preferences. Click on Language Menu/Tab settings. Under the tab settings for [Default] modify the tab size and Replace by space options as shown below. We set the tab size to 2 and we set Replace by space option to use spaces instead of tab character.
Now we will add a custom menu in the Run menu for running Ruby programs. This way you can run Ruby programs directly from the Notepad++ editor. From the Notepad++ menu, click on Run => Run. This opens up the following window.
In the text field, enter the following command. In order for this to work, you need to have Ruby 1.9.x installed and the Ruby bin folder must be on the PATH environment variable. See this tutorial for step by step instructions on installing Ruby in Windows.
cmd /K ruby "$(FULL_CURRENT_PATH)"
Click on the Save… button to save this as a custom command.
Enter a name for the shortcut (Run Ruby Program) and then select a keyboard shortcut for running the command (F6). Click on OK.
Now from the Notepad++ menu, Click on Run. You will see the additional "Run Ruby Program" menu as shown below.
In order for this shortcut to work, you need to ensure that your Ruby program is saved in a file. To test Notepad++, type in the following program,
1 | def fact(n) |
2 | if n== 1 |
3 | 1 |
4 | else |
5 | n * fact(n- 1 ) |
6 | end |
7 | end |
8 | puts fact( 5 ) |
Save the file as factorial.rb. Now press F6 key or select the "Run Ruby Program" submenu from the Run menu. You should see the output of the Ruby program in a command window as shown below,
No comments:
Post a Comment