Sublime Forum

Shortcut key for opening last closed file?

#1

Is it possible to setup a shortcut for opening the last close file? If it just went through the recently open list that would be enough :smile:

0 Likes

#2

If you open Main.sublime-menu you can see all the commands in the application menus. The most-recent-file command is this one:

{ "command": "open_recent_file", "args": {"index": 0 } },
I believe from my brief testing just now that files are added to this list when they’re closed, not when they’re opened, so it should be perfect for you. I think I might also make a keybinding for this, come to think of it…

0 Likes

#3

Thanks adzenith, you are my hero :smile:

0 Likes

#4

Ok so i’ve added the below to my keymap

{ "keys": "super+shift+t"], "command": "open_recent_file", "args": {"index": 0 } }

But how can I go about making it so index is increased on each press as it currently only works with literally the last closed file, but it soooo close to being awesome!

0 Likes

#5

[quote=“Phunky”]Ok so i’ve added the below to my keymap
But how can I go about making it so index is increased on each press as it currently only works with literally the last closed file, but it soooo close to being awesome![/quote]

This made no sense when I first read it, but now I understand (in my excitement I didn’t test all of the use cases). The problem is that you don’t want it to increment the index every time, just when the file is already open. I guess this would have to be done with a plugin that has access to the recently used file list as well as a list of the currently opened files. Upon invocation, the plugin would loop through the recently used files until it found the first one that is no longer open (and then it would open that file).

@jps: are there any api methods that could give us this information?

0 Likes

#6

Can anyone help suggest how I can iterate through all the files in the recently closed list?

What would be really nice is if it kept the files buffer too and had all the history from when it was first opened :smiley: that would be really awesome!

1 Like

#7

I want this too.

0 Likes