18

I use notepad++ from Wine.

I want to set Notepad++ as one of the default editors. I tried to set it by right-clicking on a file, then Open With. But I did not see Notepad++ in the resulting list (even after clicking on Choose Other Programs).

3
  • 3
    There are plenty editors for *nix systems, much better than Notepad++ and other win stuff. Try Geany, and forgot about crappy win apps. Jun 4, 2016 at 18:17
  • As @lustful-rat said, a good alternative would be Gedit.
    – user423626
    Jun 4, 2016 at 18:20
  • People suggesting gedit or geany have never used Notepad++ heavily. Notepad++ is packed with features that those editors don't have.
    – Trevor
    Jun 18, 2020 at 5:46

8 Answers 8

5

You can use the mimeopen command

Using a terminal go to a folder containing some extension you want to open with notpadd++(here i'm testing for txt files)

mimeopen -d file.txt

You will get a popup menu, where you can see some options, if you don't find notepad++ with them choose other and indicate your notepad++ .

Also you may interested in reading Change all associations from gedit to another application

5

I guess the best advanced option gives you Ubuntu Tweak tool.

enter image description here

Here you can set your default (desired) app to any format/extension.

More detailed described here

3

Instead of using Notepad++ through Wine, you can directly install Notepadqq in Ubuntu. You can consider it as Ubuntu version of Notepad++. Notepadqq can be installed as follows:

sudo add-apt-repository ppa:notepadqq-team/notepadqq
sudo apt-get update
sudo apt-get install notepadqq
sudo apt-get install notepadqq-gtk
4
  • @Aadishri Thanks for going in-depth of my answer but your link is giving a 404 error. There is an extra angular bracket '>' at the end. Jan 20, 2017 at 7:37
  • 1
    Notepadqq has an annoying bug github.com/notepadqq/notepadqq/issues/336
    – Aadishri
    Jan 20, 2017 at 7:52
  • 3
    Notepadqq lacks features, not least of which the Plugin Manager. Jul 13, 2017 at 18:57
  • 5
    This does not answer the question Dec 1, 2017 at 19:26
1

I have followed the below steps and that exactly made me to fix this issue and made Notepad++ as the default editor in Ubuntu.

  1. Once after installing Notepad++ using WINE, copy the file "Notepad++.desktop" under, "/.local/share/applications/wine/programs/Notepad++"

  2. We need to paste the copied file "Notepad++.desktop" in the below path "/usr/share/applications"

NOTE: The applications folder is write protected by default. So open the terminal and navigate to "/usr/share" path and execute the following command.

sudo chmod -R 777 applications

Once after copying the "Notepad++.Desktop" file, revert back this permission change made by the following command.

sudo chmod -R 555 applications

  1. Now, we need to make changes in the configuration file that exists in the gnome folder [which is a subfolder inside "etc" folder]

Note: Again here, the gnome folder is write protected by default so, open the terminal and navigate to "/usr/share" path and execute the following command.

sudo chmod -R 777 gnome

  1. Now open the "defaults.list" file inside gnome folder and replace gedit by Notepad++. You can also individually set Notepad++ as default application for certain type of file.

For example, if you want to edit only plain text files in Notepad++, n the "defaults.list" file find for "text/plain" and you will get a line as follows,

text/plain=gedit.desktop

Now replace the gedit bu Notepad++ so that, it would set the Notepad++ as default application for the plain text. The modified line should look like,

text/plain=Notepad++.desktop

Now, SAVE the file once this change is done and close the file.

[You can find a new file name defaults.list.xxxx has been created, which is nothing but the backup of old settings and you can very well delete it. Please make sure you are not deleting the other two files namely : "defaults.list.dpkg-old" and "menus.blacklist" ]

Once doing the required changes, revert back the permission change made earlier for the gnome folder by the following command.

sudo chmod -R 555 gnome

  1. That's it... You have made Notepad++ as the default editor in Ubuntu. It worked for me and I hope this post helps.
1
  • Using ubuntu, there isn't a "defaults.list" file inside of that gnome folder.. and the application folder defaults to 755 for it, not 555
    – Alkanshel
    Dec 12, 2021 at 19:45
1

Right click filetype in question (e.g. txt), and do Open With > Other Application...

Click in the Enter a custom command field below the usual list of applications. Enter:

wine C:\\windows\\command\\start.exe /Unix /home/linuxusername/.wine/dosdevices/c:/users/Public/Desktop/Notepad++.lnk

...Now click button Set as default.

Alternatively instead of Open With etc. you can use mimeopen -d yourfile.txt in Terminal, and you will get similar Use command: prompt into which you can past the above command.

You should now be able to double-click the filetype in question to open it - yay!

Notes:

  • This assumes you installed Notepad++ in wine with desktop shortcut, otherwise adapt your path.

  • linuxusername is of course to be replaced with your user name.

  • Public appears to be the default Windows user name created by the Wine install.

  • This works under pure Debian also.
1
  • This works, it takes about 5 seconds to launch notepad initially this way even on a fast computer though. I don't have that issue when opening notepad++ otherwise in ubuntu. I wonder why that is
    – Alkanshel
    Dec 12, 2021 at 20:13
0

The above answers are all great! But if you want a quicker way to do this repeatedly then this bash simple script will be useful to you!

What does it do? Simply runs mimeopen -d but also prints the wine command required to open in notpad++

I just called it ~/scripts/mimeopen.sh

Usage:

~/scripts/mimeopen.sh ./file_you_want_to_open.txt

Script:

#!/bin/bash
BLUE='\033[0;36m'
ORANGE='\033[0;33m'
NC='\033[0m'
echo
echo -e "${BLUE}Npp open command:"
echo -e ${ORANGE}
echo "wine C:\\windows\\command\\start.exe /Unix /home/$USERNAME/.wine/dosdevices/c:/users/Public/Desktop/Notepad++.lnk %f"
echo -e ${NC}
mimeopen -d $1
0

I use a fresh installed Ubuntu 22.04.1 (jammy). The simplest way I found expired by the post above was:

  1. Become super user with

sudo -i

  1. Create a "Notepad++.desktop" with your preferred editor in the path /usr/share/applications with the following content:

[Desktop Entry]
Name=Notepad++
Exec=env WINEPREFIX="/home/$USER/.wine" wine-stable C:\\\\windows\\\\command\\\\start.exe /Unix /home/$USER/.wine/drive_c/Program\\ Files/Notepad++/notepad++.exe %U
Type=Application
StartupNotify=true
Path=/home/$USER/.wine/dosdevices/c:/Program Files/Notepad++
Icon=33E8_notepad++.0
StartupWMClass=notepad++.exe

Warning: "%U" at the end of Exec=env ... %U is very important!

  1. Give permission rights with:

#chmod 755 Notepad++.desktop

That's it, and in the

File manager (I use Nautilus as default, but with Nemo works also) right click on a '.txt' (or any other files of your choice) that I want to open and >> Open With Other application >> View All Applications

scroll down and it now appear in menu.

0

As of 2023, notepad++ is available on the default install of Ubuntu as a snap:

sudo snap install notepad-plus-plus

It should then be able to be run as:

notepad-plus-plus

and should also make it's way into the right click -> Open With menu, without any additional configuration.

The benefit of using the snap repo is that you can keep it up-to-date easily:

sudo snap refresh

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .