Is there a way to open files with Notepad++ in Bash on Ubuntu on Windows?

不想你离开。 提交于 2019-12-05 19:05:32

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.

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

<path_to_textEditor> <path_to_textfile>


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

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

    vim ~/.bashrc

  2. Add the alias defintion to the script:

    alias np='<path_to_textEditor>'

    For Notepad++ it would be:

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

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

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

Now, use it like you would normally:

To open Notepad++, do np

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


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> ...'

Here are some examples:

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

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

  • -notabbar: Turn off the tab interface.

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:

  • Quickly edit individual files when I don't want to use VIM (and return to the CLI when exiting). Useful for writing git commit messages.
  • Open up files into my 'always open' standard Notepad++ session (with tabs).

I usually put all work files in Windows directory

/mnt/d/ubuntu/ 

Then in WSL Ubuntu shell, I create a symbolic link to the directory

ln -s /mnt/d/ubuntu ~/win

Whatever files I work with in WSL, I put them in this directory except for the linux specific files, which usually have no need to be opened with Windows applications.

Now, when you want to use Windows applications for the files, you simply browse the app to

D:/ubuntu/.../your/files
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!