How can gedit be forced to open a new window independently of existing gedit windows whenever a text file (.txt) is double-clicked on a Gnome desktop of Debian 8, Jessie?

Suppose that a.txt is already open in a gedit window, and that b.txt is double-clicked on a Gnome desktop of Debian 8 Jessie. Then, unfortunately, by the factory default, b.txt will be opened in a tab in the same window as a.txt.

However, I want b.txt to be opened in a new window of gedit so that there will be two windows - the existing window for a.txt and a new window for b.txt.

If Gnome invoked gedit with the "-s" option as in

gedit -s b.txt

then b.txt would be opened in a new window, while a.txt stays in its existing window.

However, by default, Gnome seems to invoke gedit without the "-s" option.

The configuration file


contains the execution directive

Exec=gedit %U

So, I changed it to

Exec=gedit -s %U

by the following commands, and restarted the computer.

cd /usr/share/applications
su # similar to sudo
mv org.gnome.gedit.desktop org.gnome.gedit.desktop.bak
perl -pe 's/Exec=gedit %U/Exec=gedit -s %U/' org.gnome.gedit.desktop.bak > org.gnome.gedit.desktop
diff org.gnome.gedit.desktop org.gnome.gedit.desktop.bak

However, this method has failed. The b.txt still opens in a tab in the same window as a.txt. I am stuck. I need your help.

The default mode of gedit is "single window, multiple tabs". I want the "multiple windows" mode.

By the way, the following useless method turns gedit into the "single window, no tab" mode, which is not what I want.

gsettings set org.gnome.gedit.preferences.ui show-tabs-mode 'never'

With this "gsettings" method, gedit automatically closes a.txt and reuses the existing window of a.txt to open b.txt in it whenever b.txt is double-clicked on a desktop. Thus, it is the "single window, no tab" mode (as opposed to "multiple windows").

(By the way, the default value for "show-tabs-mode" is 'auto'.)

  • @don I am not very familiar with launcher. What are the commands to invoke the separate launcher?
    – i7pj3qnuz
    May 5, 2017 at 1:48

2 Answers 2


The reason why your modification of the Exec key in the .desktop file did not work is that gedit is DBus activated. This means that it is launched via your session's DBus daemon and then provides a common DBus interface for such activatable programs to specify the files to open. You can prevent this by changing the DBusActivatable key to false.

Also, it is much better to create a copy of the .desktop file you want to modify in your home directory and use that to override the system-wide one than to modify the system-wide one directly. That way the system one will not be overwritten on distro package updates. To do that just copy /usr/share/applications/org.gnome.gedit.desktop to ~/.local/share/applications/org.gnome.gedit.desktop. Files in this path will override files with the same name from the system-wide directory.

Then there is also an important difference between the two possible flags used to open a new window: --new-window or -s. Both will result in the files being opened in a new window, but with -s each window will also belong to its own process. When using --new-window all windows share the same gedit process.

And finally to make sure that this also works if you select multiple files in your file manager and open them, you need another modification of the Exec key. The %U means that multiple URLs are allowed as arguments for this command, meaning that the file manager would start it like this: gedit --new-window file1.txt file2.txt. This results in a single new window with two tabs. If you change this to %u now, that tells the file manager, that the application only accepts a single URL as an argument and therefore causes it to run the command multiple times, each time with a different file as its argument. For more details on this see the freedesktop desktop entry specification.


Based on Sebastians answer, do the following:

  1. Make a local copy of the gedit configurations. The changes you do, apply only to the current user then.

    cp /usr/share/applications/org.gnome.gedit.desktop ~/.local/share/applications/geditNewWin.desktop

  2. In the file ~/.local/share/applications/geditNewWin.desktop: Go to all EXEC= lines (there are a few) and set them toExec=gedit -s %U. Further change Name=Text Editor to Name=Text Editor (new window). (if you don't see a name change, try editing also the line 'Name[en_GB]=' or the one that corresponds to your language setting).

  3. In your File Manager (eg: Nautilus, or standard file manager in Gnome, often called just 'Files' or Gnome Files, or Caja in linux MATE, etc.) associate the filetypes (.txt, .csv, ...) with your newly created application:

  • rightclick on a .txt file (or whatever filetype you want)
  • click 'Properties'
  • chose tab 'Open With'
  • select 'Text Editor (new window)' from the list
  • click on 'Set as default'

You must log in to answer this question.

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