In Nautilus on Ubuntu Desktop 14.04, when I choose "open with" and then select "Sublime", the document will always open in any existing instance you have open. If I use the CLI and call subl --new-window [path to file] then I get the desired behaviour.

How can I add the --new-window argument to the call that nautilus is executing to open with Sublime?

  • 1
    Easily done editing by sublime's .desktop or thru a nautilus action, But - The default for sublime is to remember/re-open last session. So in that case if you edit the .desktop or a nautilus action is used on a file with sublime not open you'll get 2 windows opening - the new one & one reflecting previous session/tabs. So editing the .desktop is out unless you want to disable that feature. If using NA then you'd only use it when sublime is already open. Which do you prefer? – doug Jul 10 '15 at 12:42
  • I have disabled sublime from remembering my previous session/tabs so I just need to update .desktop, now just to figure out what exactly that means... – Programster Jul 10 '15 at 13:03
  • Great I just had to replace Exec=/opt/sublime_text/sublime_text %F with Exec=/opt/sublime_text/sublime_text -n %F (see the -n) in the file: /usr/share/applications/sublime_text.desktop. If you put up such an answer I will mark it as the correct solution. – Programster Jul 10 '15 at 13:19

The easiest is just to edit sublime's .desktop & add the -n option to the Exec= line. This works well when one has disabled sublime's default of remembering the last session.

To do so just run sudo nano /usr/share/applications/sublime-text.desktop & add -n to the Exec= line so it looks like -

Exec=/opt/sublime_text/sublime_text -n %F

Also to note - on some systems sublime will cause cursor run on when used from the context menu. If that's the case while the .desktop is open to edit scroll down to the StartupNotify=true line & make it StartupNotify=false. This will prevent cursor run on..

(- for those not used to nano - after editing go -


press enter key on keyboard



It is a simple question but a tricky one to answer. I haven't used Sublime myself but problem is similar with Gedit as well. If you prefer you can use Nautilus actions to add a context-menu item. Install it through Software center.

If you want to create Nautilus script you will have to use $@ characters as substitution of environment variable NAUTILUS_SCRIPT_SELECTED_FILE_PATHS:

for i in "$@"; do 
    gedit --new-window "$i" & xdotool search --sync --onlyvisible --name "$i" windowactivate
exit 0

The -xdotool here is to raise windows because they all runs in the background but you can alter the behavior the way you are familiar with, spread them around or just live it alone the way it is.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.