Sublime Forum

Default folder to save new files

#1
  1. Create new project
  2. Add folder to project
  3. Open that folder in sidebar
  4. CTRL+n
  5. CTRL+s

Save dialog ask to save file into home directory

EXPECTED: save dialog must ask to save file into current folder in sidebar

Please fix this behaviour.
Thank you

0 Likes

#2

Right click any folder in the sidebar and select New File. Select Save and the file will be saved in that folder.

0 Likes

#3

I understand that, but it is not fixing BUG when using CTRL+n

0 Likes

#4

Not a bug, it’s a feature.

Most, probably all, software that implements save as dialogs uses the same default path that you last saved to. This is an OS default. While what you are requesting is not unreasonable, it’s not a bug report but a feature request (meaning you are in the correct forum).

By the way, you can implement this yourself using a small plugin.

[code]import sublime_plugin

class NewFileListener(sublime_plugin.EventListener):
def on_new_async(self, view):
if not view.window() or not view.window().folders():
return
view.settings().set(‘default_dir’, view.window().folders()[0])[/code]

0 Likes

#5

This issue also troubled me .

In old SublimeText , when I create an new untitled file, the default save-folder is as same as the opened file in current view.
But now, the default save-folder depends on Mac OS .

I like the older behavior .

0 Likes

#6

Ok , I wrote a plugin ( for sublime text 3 ) for this request.

gist.github.com/finscn/8bc573bb3a970b1c214d

0 Likes

#7

COOL!

0 Likes

#8

Amazing !

0 Likes

#9

Super

0 Likes

#10

I’ve a question. Will this stop Sublime - on Windows, at least - from offering to save new files . . in the folder from which SublimeText runs itself? That behaviour is bonkers. For, if I open Sublime, write a note, and wish to save it on my desktop, then Sublime offers to save the file . . in C:\Program Files\SublimeText (or some such). Very, very irritating.

0 Likes

#11

I don’t care if it is a feature or a bug. The current way that Sublime Tex 3 handles file save is just stupid.

Very often you start Sublime Text 3 from the terminal, the editor perfectly knows the current working directory, and that’s one there in the sidebar. Then you create a new file, or just type something, and then save in the Save window – guess where the file would go?

So initially I navigated to a very deep folder using my terminal, and then start Sublime Text 3 there. When I save, I need to do the navigation in the Save window again. Not to mention that some folders are hidden in macOS by default, so you just cannot find them (e.g. ~/Library).

This happened too many times – when I open my Sublime Text 3 from the terminal and save my file using the defaults, the file goes to an unexpected place. After close Sublime Text 3 I begin to realize that the file isn’t there, so I have to open Sublime Text 3 again and use File --> Open Recent to find where it is and move it to where it should be.

The code that FichteFoll mentions works partially, it helps when you New File and then Save, but it doesn’t help when you open Sublime Text 3 and type and just save that untitled, tab-less draft file. Of course, thanks for the code.

I am using macOS. Save the below code by FichetFoll as

~/Library/ApplicationSupport/Sublime\ Text\ 3/Packages/User/NewFile.py

and it should be loaded by Sublime Text 3 automatically at start-up and will do some help.

import sublime_plugin

class NewFileListener(sublime_plugin.EventListener):
    def on_new_async(self, view):
        if not view.window() or not view.window().folders():
            return
        view.settings().set("default_dir", view.window().folders()[0])
0 Likes