java 如何在cmd中使notepad ++功能像普通记事本一样?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/27107723/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-11-02 11:14:38  来源:igfitidea点击:

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

javacmdnotepad++

提问by Dziugas

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

我喜欢使用命令提示符来编写和编译 java。要编写代码,我在 cmd 中输入:

notepad MyJavaClass.java

记事本 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.

这将打开记事本并询问我是否要创建新文件(如果它不存在)。我的问题是我喜欢使用 notepad++ 作为文本编辑器,因为它有很好的功能。

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++?

我如何做到这一点,以便我可以在 cmd 中输入“notepad++ MyJavaClass.java”并打开 notepad++,准备好进行编辑,而无需输入 notepad++ 的完整路径?

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

我试图简单地将 notepad++.exe 文件放在 System32 文件夹中,但 cmd 无法识别该命令。

Sorry for the noobiness :)

很抱歉没有礼貌:)

回答by mojo

Notepad++ is a known app, so if you launch it with the STARTbuiltin, it'll work without having to modify the PATH.

Notepad++ 是一个已知的应用程序,因此如果您使用START内置程序启动它,它无需修改PATH.

start notepad++ MyJava.java

回答by Alexander Kohler

Add notepad++ to your path

将记事本++添加到您的 path

In Windows (Using GUI):

在 Windows 中(使用 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:

转到 PATH 用户变量并单击编辑,并将您的路径附加到 notepad++ 到末尾。例如:

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

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)

在 Windows 中(使用以管理员身份运行的命令行)

To set only for the duration of command line session:

仅在命令行会话期间设置:

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

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

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

要永久设置,请使用与上面相同的命令,但替换setsetx

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

请注意,并非所有 Windows 发行版都带有 setx,可以在此处手动安装。

回答by Dziugas

HKEY_CURRENT_USER\Software\Microsoft\Command Processor
Autorun 
path %userprofile%\desktop;%path%&doskey /macrofile="%userprofile%\macros.txt"

Here I'm adding a path, then setting the doskey macros.

在这里,我添加了一个路径,然后设置了 doskey 宏。

You could do this

你可以这样做

doskey /macrofile="%userprofile%\macros.txt"

In the macros.txt do this

在 macros.txt 中执行此操作

n="c:\somewhere\notepad++.exe" $*

Now you just type

现在你只需输入

n <filename>

See

set /?
doskey /?
cmd /?