Created
June 19, 2015 07:39
-
-
Save finscn/8bc573bb3a970b1c214d to your computer and use it in GitHub Desktop.
A plugin of SublimeText 3 : Let the FOLDER of a new untitled file be as same as the folder of current activated file.
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
# NewFileAtCurrentFolder | |
import sublime_plugin | |
import os.path | |
class NewFileListener(sublime_plugin.EventListener): | |
def on_new_async(self, view): | |
if not view.window().active_view(): | |
print("NF: no view") | |
return | |
newView = view.window().active_view() | |
index = view.window().views().index(newView) | |
lastView = view.window().views()[index - 1] | |
if not lastView: | |
print("NF: no lastView") | |
return | |
fileName = lastView.file_name() | |
if not fileName: | |
print("NF: no fileName") | |
return | |
basePath = os.path.dirname(fileName) | |
if not basePath: | |
print("NF: no basePath") | |
return | |
print("NF: "+basePath) | |
newView.settings().set('default_dir', basePath) |
This is what I need. Thank you. :)
Not sure why they changed it. This is much better, thank you!
In case anybody is wondering where to save this file.
Just drop the NewFile.py
file into your Packages/User
folder within your Sublime folder.
For Sublime 3 this is my location (where <your_name>
is, your name):
/Users/<your_name>/Library/Application Support/Sublime Text 3/Packages/User
Very helpful - thank you!
Thanks for this.
@RonanC Thanks!
Great!
Awesome!
what about st4?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thank you!