Skip to content

Instantly share code, notes, and snippets.

@kirillgashkov
Last active January 21, 2019 18:34
Show Gist options
  • Save kirillgashkov/b26357405df1480647532cf058ec431f to your computer and use it in GitHub Desktop.
Save kirillgashkov/b26357405df1480647532cf058ec431f to your computer and use it in GitHub Desktop.
Sublime Text 3 command that creates a new file inheriting the syntax of the active one.

Installation

Manual

  1. Put SugaryNewFileCommand.py under Packages/User
  2. Add new key binding { "keys": ["super+n"], "command": "sugary_new_file" }
  3. Done.
import sublime_plugin
class SugaryNewFileCommand(sublime_plugin.WindowCommand):
"""
Creates new file inheriting the syntax of the active one.
"""
def run(self):
# get current window
current_window = self.window
# get current file's syntax
current_syntax = current_window.active_view().settings().get('syntax')
# create new file
new_view = current_window.new_file()
# set new file's syntax
new_view.set_syntax_file(current_syntax)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment