Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sublime Text 2 - Key Binding for Open Recent?

Tags:

sublimetext

How can I map Open Recent, or "open last file" to a keyboard shortcut?

This is my pitiful attempt so far:

{ "keys": ["super+shift+r"], "command": "open_recent"}

I tried looking at the console (Ctrl-`) while using Open Recent but it doesn't display anything.

In general, how does one go about adding key bindings? And is there a more appropriate place that Stack Overflow for this question?

Thanks!

like image 530
Thomas David Baker Avatar asked Dec 11 '11 12:12

Thomas David Baker


3 Answers

Key bindings should be added to the User key-binding preferences. Adding to the default settings will also work, but the settings will be overwritten when a new version of Sublime Text 2 is installed.

Your attempt matches the general structure of a Sublime Text key-binding, but "open_recent" isn't a valid command. From what I can find in the documentation, I think the Open Recent menu keeps track of the different file names then calls open on whichever file is selected, instead of calling an open_recent command.

If there isn't a way to get the name of the most recent file, you could probably write an extension that kept track of the most recent file and then opened it, but that probably be a fairly kludgy solution.

like image 195
Colin R Avatar answered Sep 23 '22 15:09

Colin R


The command is reopen_last_file. So you should add something like this:

{ "keys": ["ctrl+shift+r"], "command": "reopen_last_file" },

Little PS: I'm using ctrl+shift+t, so that the shortcut for reopening the last document is consistent across my browser, IDE and editor.

like image 25
Halil Özgür Avatar answered Sep 24 '22 15:09

Halil Özgür


I suggest you try out a couple of packages:

https://github.com/spadgos/sublime-OpenRecentFiles

or:

https://github.com/paccator/GotoRecent

And the easiest way to install them is with this package control, package: http://wbond.net/sublime_packages/package_control/installation

That should give you what you want...

like image 42
zeroasterisk Avatar answered Sep 23 '22 15:09

zeroasterisk