Search code examples
javacmdnotepad++

How to make notepad++ function like regular notepad in cmd?


I like using the command prompt to write and compile java. To write the code I enter this in cmd:

notepad MyJavaClass.java

This opens notepad and asks if I want to create new file (If it doesn't already exist). The problem for me is that I like using notepad++ as a text editor because it has nice features.

So my question is:

How do I make it so that I can type "notepad++ MyJavaClass.java" in cmd and have notepad++ open up, ready for editing without having to type the full path of notepad++?

I tried to simply place the notepad++.exe file in the System32 folder, but cmd doesn't recognize the command.

Sorry for the noobiness :)


Solution

  • Add notepad++ to your path

    In Windows (Using GUI):

    From the Start Menu, right-click Computer, select Advanced system settings in the left area, then select Environment Variables at the bottom in the window that pops up.

    Go to the PATH user variable and click edit, and append YOUR path to notepad++ to the end. For example:

    C:\Program Files (x86)\Notepad++;

    Don't forget the semi-colon! Be sure the entry before it is also ended with a semi-colon.

    In Windows (Using command line running as Administrator)

    To set only for the duration of command line session:

    set PATH=%PATH%;C:\Program Files (x86)\Notepad++;

    To permanently set, use the same command as above but replace set with setx:

    Note that not all Windows distributions come with setx, and can be manually installed here.