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).
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).
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
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
I have followed the below steps and that exactly made me to fix this issue and made Notepad++ as the default editor in Ubuntu.
Once after installing Notepad++ using WINE, copy the file "Notepad++.desktop" under, "/.local/share/applications/wine/programs/Notepad++"
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
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
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
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.
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
I use a fresh installed Ubuntu 22.04.1 (jammy). The simplest way I found expired by the post above was:
sudo -i
/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!
#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.
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