9

I would like to configure gedit so that everytime I double click on a text file it will open on a new window instead of a new tab. How can this be done?

Something like,

gedit --new-window "file name"

, but with a double click

Using ubuntu 12.04 with cinnamon, and gedit - Version 3.4.1

7 Answers 7

10

I also need this. I suddenly find simpler solution:

sudo nautilus /usr/share/applications/

Point to gedit, hit Alt+Enter (Properties), and replace command to

gedit -s %U

Tested on Xubuntu 12.04.2 LTS. Hope it helps.

2
  • This works but also opens every new file MAXIMIZED. Causing the new instance to cover the entire screen
    – Chris
    Jul 26, 2017 at 19:18
  • To clarify, the file you want may be called /usr/share/applications/org.gnome.gedit.desktop rather than gedit, and you need to change Exec=gedit %U to Exec=gedit -s %U in this file. Jun 20, 2021 at 3:29
8

There is a gedit setting called notebook-show-tabs-mode, which is usually set by default to 'always', which means every new document opened will open in a tab. However, if you set it to 'auto' by entering the command below in the terminal, gedit will not open in a tab unless another document is currently open.

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

However, if you want to make sure that no tabs are ever opened, choose the 'never' setting, so that is probably what you want. You may then need to use the File menu within gedit to switch between documents, although gedit will still warn you when you try to close it if there are still unsaved documents. This is the command you want in this case:

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

To return to the default settings, use 'always' in the command above instead. You can also find the whole list of hidden settings for gedit by entering

gsettings list-recursively | grep -i gedit

but I think the notebook-show-tabs-mode setting is maybe the one you want.


However, after considering your comment, I think you could also use the standalone (-s) gedit option, as that will open each new document in a new window. Create a .desktop file like this and make it executable and put in ~/.local/share/applications:

[Desktop Entry]
Type=Application
Name=gedit_alternative
Comment=gedit standalone
Exec=/usr/bin/gedit -s %U
Terminal=false
GenericName=

Then simply associate it with text files by editing ~/.local/share/applications/mimeapps.list and add the following to these sections of the file (backing it up first):

[Default Applications]
text/x-log=geditspecial.desktop
text/plain=geditspecial.desktop

and

[Added Associations]
text/x-log=geditspecial.desktop;
text/plain=geditspecial.desktop;

Replace geditspecial with the name of your own .desktop launcher. Now when you click text files they will all open in separate instances.

2
  • 4
    this no longer works on trusty and higher Mar 13, 2017 at 7:56
  • 2
    'notebook-show-tabs-mode' is now 'called show-tabs-mode', but it does not do the job in my case Mar 15, 2019 at 10:17
5

For Nautilus and other GUI instances

Edit your /usr/share/applications/gedit.desktop file add the argument --new-window to the Exec= entry:

Change from:

[Desktop Entry]
Name=gedit
GenericName=Text Editor
Comment=Edit text files
Exec=gedit %U
Terminal=false

Change to:

[Desktop Entry]
Name=gedit
GenericName=Text Editor
Comment=Edit text files
Exec=gedit --new-window %U
Terminal=false

For the commandline

That takes care of the nautilus and other gui instances. For the commandline use the alias in ~/.bashrc as mentioned by Leocadio González Casado above. Append this to your ~/.bashrc file.

alias gedit="gedit --new-window"

Note:
This works with all Ubuntu versions.

2
  • 1
    maybe its better to copy the '/usr/share/applications/gedit.desktop' file first to '~/.local/share/applications/gedit.desktop' first and modify the copied version. You can change additionally. This just overwrites the configuration for the current user Mar 15, 2019 at 10:21
  • In 22.04 I had to also change DBusActivatable=false in that Desktop Entry file. Source: askubuntu.com/a/1225659/986830
    – joe
    Jan 26 at 12:33
1

Very good feature for multimonitor configuration to look at the one file and edit other. But some time we may use single window configuration. To use both:

  1. Run (as it described by user2223633):

    sudo nautilus /usr/share/applications/

  2. Point to gedit and create a copy (ctrl + c, ctrl + v).

  3. Rename the copy to a name understandable for You.

  4. Point to new gedit copy.

  5. Hit Alt+Enter or RightClick -> Properties (as it described by user2223633).

  6. Replace command to (as it described by user2223633):

    gedit -s %U

  7. Close the Nautilus window (opened by root) as soon as possible.

  8. Open a Nautilus window or use Desktop and point to any text file

  9. Rightclick it and point to Open With - Other program.

  10. If You see both gedit and it's copy the configuration is finished. If not press "Show other program" and open the file with gedit copy.

  11. Repeat 9 and 10 opening by gedit not by copy.

Now You can open file using both modes using Rightclick - Open With - Other program.

Tested by Ubuntu 13.04 X64

0

In my installation of Ubuntu 14.10, once gedit is opened, right click on the launcher icon will display a selection list. The first entry in the list is, "Open a New Window".

That works for what I need.

0

To do it in the command line just add the following line to you ~/.bashrc

alias gedit="gedit --new-window"
0

Ubuntu 18.04 LTS=

sudo nautilus /usr/share/applications/

right-click Text Editor > Open with Other Application > Text Editor

(you need gedit.desktop not org.gnome.gedit.desktop) > change-

gedit %U

to

gedit -s %U

You must log in to answer this question.

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