Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
434 views
in Technique[技术] by (71.8m points)

sublimetext - Sublime Text 2 - Default Document Type

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

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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

Paste this in:

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 call it NewTabSyntax.py. New tabs will now default to Powershell.

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

view.settings().get('syntax')

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...