├── .python-version ├── Default.sublime-keymap ├── Default (OSX).sublime-keymap ├── default_file_type.sublime-settings ├── default_file_type.py ├── LICENSE └── README.md /.python-version: -------------------------------------------------------------------------------- 1 | 3.8 -------------------------------------------------------------------------------- /Default.sublime-keymap: -------------------------------------------------------------------------------- 1 | [ 2 | { "keys": ["ctrl+n"], "command": "default_file_type" } 3 | ] 4 | -------------------------------------------------------------------------------- /Default (OSX).sublime-keymap: -------------------------------------------------------------------------------- 1 | [ 2 | { "keys": ["super+n"], "command": "default_file_type" } 3 | ] 4 | -------------------------------------------------------------------------------- /default_file_type.sublime-settings: -------------------------------------------------------------------------------- 1 | { 2 | "default_new_file_syntax": "Packages/Java/Java.tmLanguage", 3 | "use_current_file_syntax": true 4 | } 5 | -------------------------------------------------------------------------------- /default_file_type.py: -------------------------------------------------------------------------------- 1 | import sublime_plugin 2 | import sublime 3 | 4 | 5 | class DefaultFileTypeCommand(sublime_plugin.WindowCommand): 6 | 7 | def run(self): 8 | w = self.window 9 | settings = sublime.load_settings("default_file_type.sublime-settings") 10 | 11 | if settings.get('use_current_file_syntax') and w.active_view(): 12 | syntax = w.active_view().settings().get('syntax') 13 | else: 14 | syntax = settings.get('default_new_file_syntax') 15 | 16 | view = w.new_file() 17 | # sublime.error_message("%s" % syntax) 18 | view.set_syntax_file(syntax) 19 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) Nick Fisher 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | this software and associated documentation files (the "Software"), to deal in 7 | the Software without restriction, including without limitation the rights to 8 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 9 | the Software, and to permit persons to whom the Software is furnished to do so, 10 | subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 19 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 20 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | This package sets the default file type of new files to be either the same as the current file, or a predefined default. 2 | 3 | This only affects files which are created with the `Ctrl+N` shortcut (`Cmd+N` on OSX). 4 | 5 | ## Installation ## 6 | 7 | ### With Package Control ### 8 | 9 | If you have the [Package Control][package_control] package installed, you can install DefaultFileType from inside Sublime Text itself. Open the Command Palette and select "Package Control: Install Package", then search for DefaultFileType and you're done! 10 | 11 | ### Without Package Control ### 12 | 13 | Go to your Sublime Text Packages directory and clone the repository using the command below: 14 | 15 | git clone https://github.com/spadgos/sublime-DefaultFileType.git DefaultFileType 16 | 17 | ## Configuration ## 18 | 19 | Create a file in your `Packages/User` directory called `default_file_type.sublime-settings` and you can set these options: 20 | 21 | - `default_new_file_syntax` *(String)* This is the path, relative to the Sublime base directory to the language file you'd like to load as the default. Default value is `"Packages/Java/Java.tmLanguage"` 22 | - `use_current_file_syntax` *(Boolean)* Set this to `true` to use the current file's syntax for the new file. If `false`, then the default (above) will always be used. Default value is `true` 23 | 24 | Let me know if you have any problems or feature requests by adding an issue here: https://github.com/spadgos/sublime-DefaultFileType 25 | 26 | [package_control]: http://wbond.net/sublime_packages/package_control 27 | --------------------------------------------------------------------------------