Sublime Forum

Default New File?

#1

Hey guys/gals,

I bought sublime and I’m loving it! It does everything I need it to, and it couldn’t be better. I honeslty think it’s the best! However… one thing I’ve noticed that can be a little bit of a drag is creating a new file each time. Allow me to explain.

When I open sublime it defaults to “Plain Text” is there anyway that I can get it to default to “Java”?

I’ve searched everywhere and I can’t find any answers. Any ideas guys/gals?

0 Likes

CoffeeScript
Default File Type
#2

I was about to answer and say that it wouldn’t be much work to write a plugin to do that, but then I thought, “if it’s so easy, why don’t I write it?” … Boom!

github.com/spadgos/sublime-DefaultFileType

By default it will make new files (ones created with Ctrl/Cmd + N) take the same syntax as the current file. If there is no open file, or you turn off that setting, then a default will be used (set to Java, just for you :smile:)

Let me know how it goes.

I’ll try to get this added to Package Control soon. In the meantime:

cd to/your/sublime/Packages
git clone https://github.com/spadgos/sublime-DefaultFileType.git DefaultFileType
0 Likes

#3

[quote=“spadgos”]I was about to answer and say that it wouldn’t be much work to write a plugin to do that, but then I thought, “if it’s so easy, why don’t I write it?” … Boom!

github.com/spadgos/sublime-DefaultFileType

By default it will make new files (ones created with Ctrl/Cmd + N) take the same syntax as the current file. If there is no open file, or you turn off that setting, then a default will be used (set to Java, just for you :smile:)

Let me know how it goes.

I’ll try to get this added to Package Control soon. In the meantime:

cd to/your/sublime/Packages git clone https://github.com/spadgos/sublime-DefaultFileType.git DefaultFileType [/quote]

Thanks for your help. I’m using Windows, could you give me a step by step on how to do it? I’m rather new.

0 Likes

#4

[quote=“Turbocom”]

[quote=“spadgos”]I was about to answer and say that it wouldn’t be much work to write a plugin to do that, but then I thought, “if it’s so easy, why don’t I write it?” … Boom!

github.com/spadgos/sublime-DefaultFileType

By default it will make new files (ones created with Ctrl/Cmd + N) take the same syntax as the current file. If there is no open file, or you turn off that setting, then a default will be used (set to Java, just for you :smile:)

Let me know how it goes.

I’ll try to get this added to Package Control soon. In the meantime:

cd to/your/sublime/Packages git clone https://github.com/spadgos/sublime-DefaultFileType.git DefaultFileType [/quote]

Thanks for your help. I’m using Windows, could you give me a step by step on how to do it? I’m rather new.[/quote]

If you have git installed you’ll only have to run the commands in cmd.

cd "C:\Users\%username%\AppData\Roaming\Sublime Text 2\Packages" git clone https://github.com/spadgos/sublime-DefaultFileType.git DefaultFileType
(if your package folder is in another location you’ll have to modify the path in the first command)

If you don’t have git installed, you can download the package at https://github.com/spadgos/sublime-DefaultFileType/downloads, and then unpack it and move it to you package directory.

0 Likes

#5

[quote=“tretretre”]

Thanks for your help. I’m using Windows, could you give me a step by step on how to do it? I’m rather new.

If you have git installed you’ll only have to run the commands in cmd.

cd "C:\Users\%username%\AppData\Roaming\Sublime Text 2\Packages" git clone https://github.com/spadgos/sublime-DefaultFileType.git DefaultFileType
(if your package folder is in another location you’ll have to modify the path in the first command)

If you don’t have git installed, you can download the package at https://github.com/spadgos/sublime-DefaultFileType/downloads, and then unpack it and move it to you package directory.[/quote]

I really appreciate your help. I’m just wondering if there is a setting in Sublime that I have to enable in order for this plugin to work?

I downloaded the contents and I moved it to

C:\Users\REPO\AppData\Roaming\Sublime Text 2\Packages\spadgos-sublime-DefaultFileType-9c82596

Not too sure what my next steps are. Thanks.

0 Likes

#6

hopefully that should be it. In that directory, there should be no subdirectories. That is, this file should exist:

C:\Users\REPO\AppData\Roaming\Sublime Text 2\Packages\spadgos-sublime-DefaultFileType-9c82596/default_file_type.py

If that’s the case, then sublime should automatically pick it up. To see if it’s working or not, inside sublime open the python console by pressing Ctrl + ~ (tilde, the key next to the 1 on a US keyboard), and then type “sublime.log_commands(1)”. This will cause all the commands which are being executed to be logged to the console. After that, press Ctrl+N, and hopefully you should see “command: default_file_type”. If it says “new_file” then the command isn’t being run.

Afterwards, don’t forget to turn off logging with “sublime.log_commands(0)”

0 Likes

#7

[quote=“spadgos”]hopefully that should be it. In that directory, there should be no subdirectories. That is, this file should exist:

C:\Users\REPO\AppData\Roaming\Sublime Text 2\Packages\spadgos-sublime-DefaultFileType-9c82596/default_file_type.py

If that’s the case, then sublime should automatically pick it up. To see if it’s working or not, inside sublime open the python console by pressing Ctrl + ~ (tilde, the key next to the 1 on a US keyboard), and then type “sublime.log_commands(1)”. This will cause all the commands which are being executed to be logged to the console. After that, press Ctrl+N, and hopefully you should see “command: default_file_type”. If it says “new_file” then the command isn’t being run.

Afterwards, don’t forget to turn off logging with “sublime.log_commands(0)”[/quote]

Thanks for all your help. It works great and I really appreciate the time you offered me.

0 Likes

#8

Dear spadgos,
Thanks for your time that still works great st3 in OS X.
I was able to dig out the answer from google within 15min to here because your work!
you are the MAN!!

0 Likes