Home Download Buy Blog Forum Support

Shortcut key for opening last closed file?

Shortcut key for opening last closed file?

Postby Phunky on Mon Jun 06, 2011 10:01 am

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 :)
Phunky
 
Posts: 35
Joined: Mon Feb 07, 2011 5:02 pm

Re: Shortcut key for opening last closed file?

Postby adzenith on Mon Jun 06, 2011 5:20 pm

If you open Main.sublime-menu you can see all the commands in the application menus. The most-recent-file command is this one:
Code: Select all
                    { "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...
adzenith
 
Posts: 1216
Joined: Mon Oct 19, 2009 9:12 pm

Re: Shortcut key for opening last closed file?

Postby jbjornson on Tue Jun 07, 2011 10:41 am

Thanks adzenith, you are my hero :-)
jbjornson
 
Posts: 349
Joined: Tue Oct 27, 2009 4:25 pm
Location: Zurich, Switzerland

Re: Shortcut key for opening last closed file?

Postby Phunky on Tue Jun 07, 2011 11:20 am

Ok so i've added the below to my keymap

Code: Select all
{
      "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!
Phunky
 
Posts: 35
Joined: Mon Feb 07, 2011 5:02 pm

Re: Shortcut key for opening last closed file?

Postby jbjornson on Tue Jun 07, 2011 1:38 pm

Phunky wrote: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!


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?
jbjornson
 
Posts: 349
Joined: Tue Oct 27, 2009 4:25 pm
Location: Zurich, Switzerland

Re: Shortcut key for opening last closed file?

Postby Phunky on Mon Jun 13, 2011 2:52 pm

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 :D that would be really awesome!
Phunky
 
Posts: 35
Joined: Mon Feb 07, 2011 5:02 pm

Re: Shortcut key for opening last closed file?

Postby atomi on Mon Jun 13, 2011 4:11 pm

I want this too.
atomi
 
Posts: 342
Joined: Thu Jan 20, 2011 5:06 pm
Location: Los Angeles CA US


Return to Technical Support

Who is online

Users browsing this forum: Yahoo [Bot] and 31 guests