- Put SugaryNewFileCommand.py under Packages/User
- Add new key binding
{ "keys": ["super+n"], "command": "sugary_new_file" }
- Done.
Last active
January 21, 2019 18:34
-
-
Save k11v/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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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