How to change Sublime Text default save location?

Viewed 437

When I write something in the empty canvas of Sublime Text and try to save it, it defaults to / (macOS) which can get irritating.

How can I change the default save dialog location or current working directory of sublime text to say ~/Downloads/Test ?

I normally launch the app by GUI, but if a CLI solution (like environment variable) is there, which I can use as an alias, it'd be okay too.

2 Answers

In this page they address a similar question to yours https://forum.sublimetext.com/t/setting-to-change-the-default-save-location/50989. You can make minimal sublime text plugin to save files to a fixed path, you can then bind this it to a any key, even override the default save key.

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")

Then bind it to the same keys as save: command+s

Also this plugin can help you AdvancedNewFile, you can set aliases to get to the path you want faster, or modify in the plugin settings default_path to the path you want.

Related