You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm no good with Git, but there's a small feature I implemented for myself, that the name of the new file gets added from clipboard, so I'm posting it here. BTW, the plugin is compatible with Sublime Text 3, maybe you should push it to wbond so he could update the repository
"""A Sublime Text package that creates a new file from the current selection."""
import sublime, sublime_plugin
import os.path
from os.path import basename
def cap(s, l):
return s if len(s)<=l else s[0:l]
class NewFromSelection(sublime_plugin.TextCommand):
def run(self, edit):
view = self.view
# Generate the output file name from the file name currently in clipboard
fileName, fileExtension = os.path.splitext(view.file_name())
# output_filename.insert(1, " snippet")
output_filename = sublime.get_clipboard()
output_filename = cap(output_filename,250)
output_filename = output_filename + fileExtension
# Concatenate the current selections into a single string.
selected_text = ""
for region in view.sel():
selected_text = selected_text + view.substr(region)
# Create the new file.
output_view = view.window().new_file()
output_view.set_name("".join(output_filename))
output_view.insert(edit, 0, selected_text)
def is_enabled(self):
return not self.view.sel()[0].empty()
def description(self):
return "Creates a new file from the current selection."
The text was updated successfully, but these errors were encountered:
I'm no good with Git, but there's a small feature I implemented for myself, that the name of the new file gets added from clipboard, so I'm posting it here. BTW, the plugin is compatible with Sublime Text 3, maybe you should push it to wbond so he could update the repository
The text was updated successfully, but these errors were encountered: