Sublime Text 2 - Default Document Type

Is there a way to set the default document type when saving NEW FILE? I created some new files and I want to have a default value for .txt when saving NEW FILE.

+8
source share
3 answers

This plugin does this:

https://github.com/spadgos/sublime-DefaultFileType

it seems pretty cool

Edit:

Well, two things, at present, there seems to be a small mistake, so the text file syntax is not selected correctly due to spaces in the file name. In addition, you need to set "use_current_file_syntax" to false (otherwise, the new file type will use the type of files that you opened when you pressed Ctrl-N) ... Thus, the fix / workaround is this:

Put the following code in: Packages / User / default_file_type.sublime-settings

{ "default_new_file_syntax": "Packages/Text/Plain_text.tmLanguage", "use_current_file_syntax": false } 

NOTE.

Then find the file "Plain text.tmLanguage", copy and rename it (in the same folder) to "Plain_text.tmLanguage". [be sure to copy / duplicate it, not just rename it, as it may have dependencies]

Restart to be sure, and this should work. Also note that this plugin only works for new files created with Ctrl-N.

+4
source

Create a new plugin Tools > Developer > New Plugin...

Insert this into:

 import sublime, sublime_plugin class EverythingIsPowerShell(sublime_plugin.EventListener): def on_new(self, view): view.set_syntax_file('Packages/PowerShell/Support/PowershellSyntax.tmLanguage') 

Save and name it NewTabSyntax.py . New tabs will now be by default in Powershell.

You can change the syntax to whatever you prefer. To find the "path" of a particular syntax, simply open the file for that syntax, open the console (" View > Show Console ) and enter:

 view.settings().get('syntax') 
+6
source

Work after the following steps:

1.Uninstalled

2. Installed using package management

3. Test using the default setting (Jave type) <- work

4.Copy and Renamed file Sublime Text 2\Packages\Text\Plain text.tmLanguage > Sublime Text 2\Packages\Text\Plain_text.tmLanguage

5.Changed file Sublime Text 2\Packages\Default File Type\default_file_type.sublime-settings >

 `{ "default_new_file_syntax": "Packages/Text/Plain_text.tmLanguage", "use_current_file_syntax": true }` 

- Everything works.

I did not need to copy files to the Packages / User folder

@fraxel _ Thanks for all the help and quick response.

+1
source

Source: https://habr.com/ru/post/922145/


All Articles