Sublime Forum

Create file with default content from menu

#1

I would like to create a configuration file in the project directory with a default value. Much like edit_settings does. But I could not find out how to do such a thing from within the .sublime-menu file of my package.

This is what I have for now:

{
    "caption": "Project Settings",
    "command": "open_file",
    "args": {
        "file": "${folder}/.php_sublime",
    }
}

So how can I apply some default content for that file?

Thank you!

0 Likes

#2

You can use the contents key.

{
    "caption": "Project Settings",
    "command": "open_file",
    "args": {
        "file": "${folder}/.php_sublime",
        "contents": "some default\ncontent"
    }
}

Note that this is the default content (if the file already exists, it won’t insert anything), but that’s what you want anyway.

0 Likes

#3

Thank you! Exactly what I was looking for.

Say, where can I look these arguments up?

0 Likes

#4

There’s not currently an official documentation source for commands that ship with Sublime (other than the key bindings, menu entries and plugins that it also ships with) but the unofficial documentation has a list of known commands: https://sublime-text-unofficial-documentation.readthedocs.io/en/latest/reference/commands.html

0 Likes

#5

Thank you, that helped me a lot!

0 Likes