I’m used to press ctrl+shift+t to get a closed tab back in my browser that’s why I did the same thing in sublime text and since there was no such keybinding available I implemented my own plugin and added a keymap for it.
This plugin allows you to reopen closed files.
You can open more then one closed file by repeating the command.
Changelog v1.0.2:
Fixed not using package folder to save tmp file when --data commandline option is used
Changelog v1.0.1:
Fixed wrong loading filename
# openLastClosedFile plugin v1.0.2
#
# example keybinding:
# <binding key="shift+ctrl+t" command="openLastClosedFile"/>
#
# Known issues:
# there has to be one tab open to make the keybinding work
import sublime, sublimeplugin, os
# we need to be able to load the filenames when command gets called
class openLastClosedFileSecure(sublimeplugin.Plugin):
def onClose(self, view):
# untitled / not saved files have no filename
if view.fileName() <> None:
file = open(sublime.packagesPath()+"\\User\\openLastClosedFile.tmp", 'a')
file.writelines(view.fileName()+"\n")
file.close()
print sublime.packagesPath()
class openLastClosedFileCommand(sublimeplugin.TextCommand):
def run(self, view, args):
fileName = sublime.packagesPath()+"\\User\\openLastClosedFile.tmp"
if os.path.isfile(fileName):
readFile = open(fileName,"r")
lines = readFile.readlines()
readFile.close()
length = len(lines)
if length > 0:
lastline = lines[length-1]
lastline = lastline.rstrip("\n")
view.window().openFile(lastline, 0, 0)
writeFile = open(fileName, "w")
writeFile.writelines([item for item in lines[0:length-1]])
writeFile.close()
get it here: pastebin.com/rXQ3XNcb
(old version v1.0.1) pastebin.com/Fw3ZUJ1z