Gists
When I launched Sublime Text, I noticed that the error occurred. The error is as follows.
ImportError: No module named 'yaml'
I confirmed that this error occurs when the plugin of Material Theme is read. And the error started to occur after Material Theme was updated, recently.
In this report, I would like to introduce the method for removing this error. The flow is as follows.
- Download a file including library for yaml (PyYAML) from https://pypi.python.org/pypi/PyYAML
- In my environment, I downloaded
PyYAML-3.12.win-amd64-py3.5.exe.
- Unzip the downloaded file.
- You can see a directory of
yaml.
- Add the directory of
yaml to python3.3.zip.
python3.3.zip is in the directory which installed Sublime Text.
By above flow, the error can be removed. If the error of ImportError occurs for other modules, you can try to do this method. I think that although my Sublime Text is Sublime Text3 build 3143 x64, this method may be able to be used for Sublime Text2.
Overview
This is a plugin of Sublime Text 3 for submitting files to both Gist and Slack.
Description
I like to use Sublime Text for developing scripts. And when I discuss about developing scripts, I often use Slack. When I submitted a script to Slack, I had saved the script to Gist as a backup. I had done manually this on my browser. Namely, I wanted to be saving the revision of script while I’m discussing about the script at Slack. One day, I wished this process had been able to be automatically run. So I created this plugin and gislack of a CLI tool.
This is for Sublime Text. This sample is for reopening current file as a file with new file name. The current file is closed when reopening a new file.
newfilename = "new file name"
contents = self.view.substr(sublime.Region(0, self.view.size()))
window = self.view.window()
window.run_command('close_file')
view = window.new_file()
view.set_name(newfilename)
view.settings().set("auto_indent", False)
view.run_command("insert", {"characters": contents})
view.set_scratch(True)
view.run_command("prompt_save_as")
Flow of this sample
- Copy all text on current file to memory (contents).
- Close current file.
- Create new file with new file name.
- Paste contents to new file.
- Open dialog box for saving new file.
This sample is for changing file name and reopening the file with new name. The flow is as follows.
- A file (sample.py) is opened.
- Rename the file from sample.py to newsample.py.
- The opened file is replace to the file with new name.
os.rename(oldfilewithpath, newname)
view = self.view.window().find_open_file(oldfilewithpath)
if view:
view.retarget(newname)