Home Download Buy Blog Forum Support

Default New File?

Default New File?

Postby Turbocom on Sat Nov 05, 2011 5:04 pm

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?
Turbocom
 
Posts: 4
Joined: Sat Nov 05, 2011 5:02 pm

Re: Default New File?

Postby spadgos on Sat Nov 05, 2011 5:57 pm

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!

https://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 :))

Let me know how it goes.

I'll try to get this added to Package Control soon. In the meantime:
Code: Select all
cd to/your/sublime/Packages
git clone https://github.com/spadgos/sublime-DefaultFileType.git DefaultFileType
spadgos
 
Posts: 121
Joined: Thu Oct 06, 2011 12:49 am

Re: Default New File?

Postby Turbocom on Sat Nov 05, 2011 6:58 pm

spadgos wrote: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!

https://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 :))

Let me know how it goes.

I'll try to get this added to Package Control soon. In the meantime:
Code: Select all
cd to/your/sublime/Packages
git clone https://github.com/spadgos/sublime-DefaultFileType.git DefaultFileType


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.
Turbocom
 
Posts: 4
Joined: Sat Nov 05, 2011 5:02 pm

Re: Default New File?

Postby tretretre on Sat Nov 05, 2011 8:25 pm

Turbocom wrote:
spadgos wrote: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!

https://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 :))

Let me know how it goes.

I'll try to get this added to Package Control soon. In the meantime:
Code: Select all
cd to/your/sublime/Packages
git clone https://github.com/spadgos/sublime-DefaultFileType.git DefaultFileType


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.
Code: Select all
   
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.
tretretre
 
Posts: 23
Joined: Fri Oct 21, 2011 7:13 pm

Re: Default New File?

Postby Turbocom on Sun Nov 06, 2011 3:25 am

tretretre wrote:
Turbocom wrote:
spadgos wrote: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!

https://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 :))

Let me know how it goes.

I'll try to get this added to Package Control soon. In the meantime:
Code: Select all
cd to/your/sublime/Packages
git clone https://github.com/spadgos/sublime-DefaultFileType.git DefaultFileType


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.
Code: Select all
   
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.



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.
Turbocom
 
Posts: 4
Joined: Sat Nov 05, 2011 5:02 pm

Re: Default New File?

Postby spadgos on Sun Nov 06, 2011 10:30 am

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

Code: Select all
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)"
spadgos
 
Posts: 121
Joined: Thu Oct 06, 2011 12:49 am

Re: Default New File?

Postby Turbocom on Mon Nov 07, 2011 2:12 pm

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

Code: Select all
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)"



Thanks for all your help. It works great and I really appreciate the time you offered me.
Turbocom
 
Posts: 4
Joined: Sat Nov 05, 2011 5:02 pm


Return to General Discussion

Who is online

Users browsing this forum: Google [Bot] and 12 guests