有没有办法在Windows的Ubuntu上的Bash中使用Notepad ++打开文件? [英] Is there a way to open files with Notepad++ in Bash on Ubuntu on Windows?

查看:191
本文介绍了有没有办法在Windows的Ubuntu上的Bash中使用Notepad ++打开文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Windows 10上,但是我正在Windows的Ubuntu(WSL)的Ubuntu上使用Bash来熟悉Linux命令行。

I am on Windows 10 but I am using Bash on Ubuntu on Windows (WSL) to familiarize myself with the Linux command line.

我试图充分利用其功能,并认为能够打开 index.html 从Notepad ++中的CLI。这可能吗?如果是这样,我将如何进行设置?

I am trying to take full advantage of its capabilities and was thinking it would be awesome to be able to open, say, index.html from the CLI in Notepad++. Is this possible? If so, how would I go about setting it up?

一般来说,我对命令行还很陌生,而Linux命令则少得多。

I am pretty new to the command line in general, much less Linux commands.

推荐答案


在WSL中绝对可以使用Notepad ++。实际上,您可以像在普通Windows环境中一样使用它。

It is absolutely possible to use Notepad++ in WSL. In fact, you can use it in precisely the same way as if working in a normal Windows environment.

您需要创建bash 别名以便更轻松地使用以下命令:

You need to create a bash alias to allow for easier use of the following command:

< path_to_textEditor> < path_to_textfile>

要为Notepad ++创建别名,请在WSL bash中执行以下操作:

To create an alias for Notepad++, do the following in WSL bash:


  1. 打开您的 .bashrc 启动脚本(在bash为开始):

  1. Open your .bashrc startup script (runs when bash is started):

vim〜/ .bashrc

在脚本中添加别名定义:

Add the alias defintion to the script:

alias np ='< path_to_textEditor>'

对于Notepad ++,它将是:

For Notepad++ it would be:

别名np ='/ mnt / c /程序\文件\(x86\)/ Notepad ++ / notepad ++。exe'

您可能需要调整路径,如果您没有在默认目录中安装Notepad ++。

You might have to adjust the path if you didn't install Notepad++ in the default directory.

请确保使用转义字符 \ (反斜杠)转义任何特殊字符,例如空格。 / p>

Make sure to escape any special characters, like whitespaces, with the escape chatacter \ (backslash).

现在,像平常一样使用它:

Now, use it like you would normally:

要打开Notepad ++,请执行 np

To open Notepad++, do np

要在Notepad ++中打开特定文件,请执行 np < text_file>

To open a specific file in Notepad++, do np <text_file>


根据用户@ericpeters的建议,有几个有用的 Notepad ++
启动选项
想要添加到您的别名。

As suggested by user @ericpeters, there are several useful Notepad++ startup options that you might want to add to your alias.

这些启动选项附加在别名字符串的末尾,并用空格分隔。

These startup options are appended to the end of the alias string and separated by whitespaces.

alias np =’< path_to_textEditor> < startup_option_1> < startup_option_2> ...'

以下是一些示例:


  • -multiInst :打开一个新的Notepad ++实例,该实例与当前打开的Notepad ++会话(如果存在)是分开的。

  • -multiInst: Open an new Notepad++ instance that is separate from the currently opened Notepad++ session (if it exists).

-nosession :不加载上一个会话,也不将会话保存到 session.xml

-nosession: Don't load the previous session and don't save the session to session.xml.

-notabbar :关闭标签页界面。

以下是启动选项的示例:

Here's an example with startup options:

alias np='/mnt/c/Program\ Files\ \(x86\)/Notepad++/notepad++.exe -multiInst -notabbar -nosession'

我个人有两个单独的别名,一个不带启动选项,另一个带上述三个启动选项。这使我可以选择是否要:

Personally, I have two separate aliases, one without startup options and one with the three startup options above. This allows me to choose if I want to:


  • 当我不想使用VIM时快速编辑单个文件(然后返回到退出时的CLI)。

  • 将文件打开到我的始终打开的标准Notepad ++会话中(带有标签)。

这篇关于有没有办法在Windows的Ubuntu上的Bash中使用Notepad ++打开文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆