Sublime Forum

Setting to change the default save location?

#1

Ok, I’ve solved my ‘plain text files should default to the .txt extension’ problem (solution), but the worse problem by far is the default save location…

I keep opening ST to jot down a quick note, and I keep saving these notes into ST’s install directory by mistake, and it’s super annoying…

Isn’t there a setting to specify the default location? From my searching around, it seems like there isn’t, but that’s boggling my mind… Is this really not a thing we can configure…?

0 Likes

#2

I am not aware of an easier approach but here is a working solution (which requires you to use plugins).

import sublime
import sublime_plugin

class CustomSaveCommand(sublime_plugin.TextCommand):

	def run(self, edit):
		# Replace the my_custom_path with the absolute path you want.
		self.view.settings().set("default_dir", "my_custom_path")
		self.view.run_command("save")

All this is doing is setting the default_dir setting of the current view (the file you want to save) to a hard coded absolute path on disk and then calling the save command.
Follow the steps in this gist to use this plugin. The keybinding is as follows.

{"keys": ["ctrl+s"], "command": "custom_save"}

(Remember that this is actually overriding the default save defined by ctrl + s)
With this in place, you should now be able to save any new file only in that hard coded file path set above by you regardless of how or where you create a new file.

1 Like

#3

thank you @UltraInstinct05 – I can work with this…

another question: in the GitHub ticket I linked above, the default plain-text file extension is set via a "default_extension" setting… and now you’ve mentioned this "default_dir" view setting… is there a doc with a complete list of all the possible settings… I’ve found the following by searching around / researching, but they’re not complete…

https://sublimetextapi.readthedocs.io/en/latest/reference/settings.html

https://github.com/TheSecEng/Sublime-Text-API-Tracker/blob/master/sublime_api_list.json

https://sublime-text-unofficial-documentation.readthedocs.io/en/latest/customization/settings.html

0 Likes

#4

You can view all the default settings files that ship with Sublime by going to View Package File and then typing Default/.sublime-settings. In addition to that packages & plugins can have their own custom settings that they apply depending on what the package/plugin in question is doing.
As far as I know, there is no docs on all known default settings though if you install a package called PackageDev you can get auto completion within settings files. Some settings are either not documented (maybe for the reason that they are used internally & not to be fiddled with) or they might have just been overlooked. You can see the default_dir setting being used in Default/new_templates.py so that’s also kind of how people discover new things, by reading default files that ship with Subime.

0 Likes

#5

@UltraInstinct05 okay, great – thanks again!

0 Likes

#6

Found a solution without python script.

here --> Is it possible to set a default folder for project files?

2 Likes

#7

Thanks for this, and yes, it seems like using https://packagecontrol.io/packages/ProjectManager seems like the easiest and most straightforward way.

0 Likes