55

Is it possible to increase the number of recent files that appear in the File -> Open recent menu in Sublime Text 3 (Ubuntu)?

I have already read Increase number of recent projects in Sublime Text 2?

And I can't find this ~/Library folder at my PC. I can find ~/.config/sublime-text-3/Packages but there's no "Default" subfolder inside.

Community
  • 1
  • 1
kinORnirvana
  • 1,667
  • 2
  • 17
  • 22

7 Answers7

80

On OSX, at least, the Default.sublime-package is in the application itself: /Applications/Sublime Text.app/Contents/MacOS/Packages/Default.sublime-package.

To edit the config easily without changes being overwritten on update, you need a copy of Main.sublime-menu in your Packages directory ~/Library/Application Support/Sublime Text 3/Packages/Default/Main.sublime-menu

The easiest way to effect these changes is to install the excellent PackageResourceViewer by skuroda (using Package Control), then:

  1. Command+Shift+p
  2. type 'resource' and select 'PackageResourceViewer: Open resource'
  3. you see a list of available packages: select 'Default'
  4. select 'Main.sublime-menu'
  5. PackageResourceViewer now copies Main.sublime-menu into the correct location and opens the new file for editing (note: the file doesn't seem to be actually created in the filesystem until hitting save, and updates seem immediately visible without requiring an update).
  6. As per Rufus_12's answer, alter the number of open_recent_folder and open_recent_file statements that appear, increasing the index each time.

    { "command": "open_recent_folder", "args": {"index": 0 } },
    { "command": "open_recent_folder", "args": {"index": 1 } },
    { "command": "open_recent_folder", "args": {"index": 2 } },
    { "command": "open_recent_folder", "args": {"index": 3 } },
    { "command": "open_recent_folder", "args": {"index": 4 } },
    { "command": "open_recent_folder", "args": {"index": 5 } },
    { "command": "open_recent_folder", "args": {"index": 6 } },
    ...continue as many times as necessary... 
    

Update re: maintainability

As @drevicko points out, this method will not auto-update with Sublime, and may even cause conflicts in future.

@James' answer (editing the Packages/User/Default/Main.sublime-menus) is indeed update-proof, but does, unfortunately, result in a duplicate sub-menu (the duplicate entries appear for me at the very bottom of the menu). The user settings file is merged with the defaults, but in a manner which results in duplicate keys.

I find that if I update Packages/Default/Main.sublime-menus, then that file completely replaces the default (delete chunks and see your menus disappear in real time!) - my new file and the defaults are not merged.

In order to: a) avoid a duplicate entry, and b) stay current with Sublime updates, I can't see an alternative to tracking changes to the file using git, and when Sublime updates, repeating the Open Resource process (overwriting your edits), then reverting only relevant changes.

ptim
  • 14,902
  • 10
  • 83
  • 103
  • Thanks. Worked great. – dudeman Feb 12 '15 at 17:27
  • 2
    Usefull and easy with PackageResourceViewer. ty – Pedro Luz Aug 04 '15 at 11:33
  • I like that this uses Sublime to solve its own problem. – Dannid Dec 22 '15 at 20:15
  • 3
    This also works for the Recent Files in the Project menu. Look for the "Project" section in Main.sublime-menu. – chuckf Feb 17 '16 at 22:48
  • 6
    For those wanting to increase the number of recent projects, the follow the same instructions as above, but with `{ "command": "open_recent_project_or_workspace", "args": {"index": 0 } },` - in the same Main.sublime-menu (thanks @chuckf) – Dannid Feb 26 '16 at 17:38
  • 1
    If PackageResourceViewer is not installed go to Command Palette Command + Shift + p, enter Package Control: Install Package then search for PackageResourceViewer. (from http://vvvio.com/increase-the-number-of-recent-files-or-folders-in-sublime-text-3/) – reducing activity Mar 24 '17 at 07:27
  • Excellent. Thank you. – CJWEB May 11 '17 at 00:14
  • With most packages, the "User" version of the config file usually only has the options you want to change from the default, allowing others to be changed on updates. This looks like it creates a complete copy.. What happens if something is changed in an update?? Presumably it's still overridden by our new version of Main.sublime-menu?? – drevicko Mar 29 '18 at 15:47
27

The Default package in Sublime Text 3 on Linux is stored in (assuming you used the .deb installer) /opt/sublime_text/Packages/Default.sublime-package.

Default.sublime-package is a ZIP file, if you open it and extract the Main.sublime-menu file from it into ~/.config/sublime-text-3/Packages/Default/Main.sublime-menu, it can then be edited the same way as the linked answer describes.

Alternatively run following commands which will create the Default directory and extract the Main.sublime-menu file into it:

mkdir ~/.config/sublime-text-3/Packages/Default/
unzip -p /opt/sublime_text/Packages/Default.sublime-package Main.sublime-menu > ~/.config/sublime-text-3/Packages/Default/Main.sublime-menu
Sam
  • 4,475
  • 2
  • 28
  • 31
  • to edit: sudo gedit .config/sublime-text-3/Packages/Default/Main.sublime-menu. FIND: "caption": "Open Recent", "mnemonic": "R", "children": JUST ADD MORE LINES – Jadeye Mar 15 '14 at 19:21
  • 2
    On Windows: Open `%appdata%\Sublime Text 3\Packages`, add `Default` directory. Paste the edited Main.sublime-menu as described in the answer. (Yes, you can paste DOS env vars into file Explorer bar and Run... box.) – yzorg Apr 30 '14 at 17:32
18

Add this Main.sublime-menu to your %APPDATA%\Sublime Text 3\Packages\User folder. You will see an added File Menu child named Open Recent More, giving you the next same-amount of recent files/folders. (If only I could position it in the menu where I want it, though.)

[
    {
        "caption": "File",
        "mnemonic": "F",
        "id": "file",
        "children":
        [
            {
                "caption": "Open Recent More",
                "mnemonic": "R",
                "children":
                [
                    { "command": "open_recent_file", "args": {"index": 8 } },
                    { "command": "open_recent_file", "args": {"index": 9 } },
                    { "command": "open_recent_file", "args": {"index": 10 } },
                    { "command": "open_recent_file", "args": {"index": 11 } },
                    { "command": "open_recent_file", "args": {"index": 12 } },
                    { "command": "open_recent_file", "args": {"index": 13 } },
                    { "command": "open_recent_file", "args": {"index": 14 } },
                    { "command": "open_recent_file", "args": {"index": 15 } },
                    { "command": "open_recent_file", "args": {"index": 16 } },
                    { "caption": "-" },
                    { "command": "open_recent_folder", "args": {"index": 8 } },
                    { "command": "open_recent_folder", "args": {"index": 9 } },
                    { "command": "open_recent_folder", "args": {"index": 10 } },
                    { "command": "open_recent_folder", "args": {"index": 11 } },
                    { "command": "open_recent_folder", "args": {"index": 12 } },
                    { "command": "open_recent_folder", "args": {"index": 13 } },
                    { "command": "open_recent_folder", "args": {"index": 14 } },
                    { "command": "open_recent_folder", "args": {"index": 15 } },
                    { "command": "open_recent_folder", "args": {"index": 16 } },
                    { "caption": "-" }
                ]
            }
        ]
    }
]
James Koss
  • 523
  • 5
  • 10
  • Thanks. It doesn't replace the default Open Recent menu, but at least this solution doesn't make me hate myself. Honestly, this should be the default suggestion for anyone desiring this functionality. – nick Nov 02 '16 at 05:00
  • Works great! I added it as a symbolic link to the actual file I keep in Dropbox. My way to make it "upgrade proof" to some degree, at least if I upgrade my machine and need to reinstall Sublime. – Puneet Lamba Jun 06 '20 at 15:08
10

For those of you who are too lazy to copy and paste then change the numbers, here is 50 of them.

                { "command": "open_recent_file", "args": {"index": 0 } },
                { "command": "open_recent_file", "args": {"index": 1 } },
                { "command": "open_recent_file", "args": {"index": 2 } },
                { "command": "open_recent_file", "args": {"index": 3 } },
                { "command": "open_recent_file", "args": {"index": 4 } },
                { "command": "open_recent_file", "args": {"index": 5 } },
                { "command": "open_recent_file", "args": {"index": 6 } },
                { "command": "open_recent_file", "args": {"index": 7 } },
                { "command": "open_recent_file", "args": {"index": 8 } },
                { "command": "open_recent_file", "args": {"index": 9 } },
                { "command": "open_recent_file", "args": {"index": 10 } },
                { "command": "open_recent_file", "args": {"index": 11 } },
                { "command": "open_recent_file", "args": {"index": 12 } },
                { "command": "open_recent_file", "args": {"index": 13 } },
                { "command": "open_recent_file", "args": {"index": 14 } },
                { "command": "open_recent_file", "args": {"index": 15 } },
                { "command": "open_recent_file", "args": {"index": 16 } },
                { "command": "open_recent_file", "args": {"index": 17 } },
                { "command": "open_recent_file", "args": {"index": 18 } },
                { "command": "open_recent_file", "args": {"index": 19 } },
                { "command": "open_recent_file", "args": {"index": 20 } },
                { "command": "open_recent_file", "args": {"index": 21 } },
                { "command": "open_recent_file", "args": {"index": 22 } },
                { "command": "open_recent_file", "args": {"index": 23 } },
                { "command": "open_recent_file", "args": {"index": 24 } },
                { "command": "open_recent_file", "args": {"index": 25 } },
                { "command": "open_recent_file", "args": {"index": 26 } },
                { "command": "open_recent_file", "args": {"index": 27 } },
                { "command": "open_recent_file", "args": {"index": 28 } },
                { "command": "open_recent_file", "args": {"index": 29 } },
                { "command": "open_recent_file", "args": {"index": 30 } },
                { "command": "open_recent_file", "args": {"index": 31 } },
                { "command": "open_recent_file", "args": {"index": 32 } },
                { "command": "open_recent_file", "args": {"index": 33 } },
                { "command": "open_recent_file", "args": {"index": 34 } },
                { "command": "open_recent_file", "args": {"index": 35 } },
                { "command": "open_recent_file", "args": {"index": 36 } },
                { "command": "open_recent_file", "args": {"index": 37 } },
                { "command": "open_recent_file", "args": {"index": 38 } },
                { "command": "open_recent_file", "args": {"index": 39 } },
                { "command": "open_recent_file", "args": {"index": 40 } },
                { "command": "open_recent_file", "args": {"index": 41 } },
                { "command": "open_recent_file", "args": {"index": 42 } },
                { "command": "open_recent_file", "args": {"index": 43 } },
                { "command": "open_recent_file", "args": {"index": 44 } },
                { "command": "open_recent_file", "args": {"index": 45 } },
                { "command": "open_recent_file", "args": {"index": 46 } },
                { "command": "open_recent_file", "args": {"index": 47 } },
                { "command": "open_recent_file", "args": {"index": 48 } },
                { "command": "open_recent_file", "args": {"index": 49 } },
Athul Raj
  • 21
  • 6
A Web-Developer
  • 868
  • 8
  • 29
6

On Windows 7 or 8 you:

  1. Open the following file in a ZIP/archive utility:
    C:\Program Files\Sublime Text 3\Packages\Default.sublime-package

  2. Extract only the file Main.sublime-menu into:
    %APPDATA%\Sublime Text 3\Packages\Default
    (Create the folder if necessary)

    The folder is otherwise known as:
    C:\Users\YourUsername\AppData\Roaming\Sublime Text 3\Packages\Default

  3. Open Main.sublime-menu (a JSON file) that you just extracted and alter the number of open_recent_folder and open_recent_file statements that appear, increasing the index each time.

        { "command": "open_recent_folder", "args": {"index": 0 } },
        { "command": "open_recent_folder", "args": {"index": 1 } },
        { "command": "open_recent_folder", "args": {"index": 2 } },
        { "command": "open_recent_folder", "args": {"index": 3 } },
        { "command": "open_recent_folder", "args": {"index": 4 } },
        { "command": "open_recent_folder", "args": {"index": 5 } },
        { "command": "open_recent_folder", "args": {"index": 6 } },
        ...continue as many times as necessary...
    
  4. Hit save and the menu should be instantly updated. :-)

You can even move your recent file/folder list into the root "File" menu for easier access.

Simon East
  • 55,742
  • 17
  • 139
  • 133
Rufus_12
  • 392
  • 1
  • 5
  • 14
5

I found you don't actually need to override the main menu;
just add your own menu which will appear in the end.

Create this new file (path for me in linux, in Sublime Text 3):
~/.config/sublime-text-3/Packages/User/Main.sublime-menu

In that file put something similar to OdatNurd previous answer;

(and I copy paste the same content into the files:
Context.sublime-menu
Side Bar.sublime-menu
to have the same submenu show up there)


I just made my own submenu from my own initials "elm" and put all stuff I personally use there with various "children" subtrees.

As a bonus, it will automatically show keyboard shortcuts to the same command behind it,
so I also use it as a reminder for actions that I don't use very often and forget the keyboard shortcut of.


This works for Sublime Text 3,
but perhaps someone can test if this also works for Sublime Text 2?


My file looks something like this:
(also added some more ideas (beside plenty recent files) for inspiration)

[
    {
        "caption" : "elm",
        "mnemonic": "M",
        "children": [
            {
                "caption": "Open Recent",
                "mnemonic": "R",
                "children": [
                    { "command": "reopen_last_file", "caption": "Reopen Closed File" },
                    { "caption": "-" },
                    { "command": "open_recent_file", "args": {"index": 0 } },
                    { "command": "open_recent_file", "args": {"index": 1 } },
                    // ... etc.
                    { "command": "open_recent_file", "args": {"index": 29 } },
                ],
            },
            {
                "caption": "Multi Line/Caret editing",
                "children": [
                    {
                        "caption": "split_selection_into_lines",
                        "command": "split_selection_into_lines",
                    },
                    {
                        "caption": "Add caret above (select_lines)",
                        "command": "select_lines",
                        "args": {"forward": false},
                    },
                    {
                        "caption": "Add caret below (select_lines)",
                        "command": "select_lines",
                        "args": {"forward": true},
                    },
                ]
            },
            {
                "caption": "Bookmarks",
                "children": [
                    {
                        "caption": "toggle_bookmark",
                        "command": "toggle_bookmark",
                    },
                    {
                        "caption": "prev_bookmark",
                        "command": "prev_bookmark",
                    },
                    {
                        "caption": "next_bookmark",
                        "command": "next_bookmark",
                    },
                ]
            },
            {
                "caption": "paste_from_history",
                "command": "paste_from_history",
            },
            {
                "caption": "Jump to matching bracket",
                "command": "move_to", "args": {"to": "brackets"},
            },
            // ... etc. etc.
        ],
    },
]

Bit off topic for just more recent files, but I thought this approach might also improve other usability and maintainability aspects at the same time :)

MoonLite
  • 4,981
  • 2
  • 21
  • 13
1

I have come recently to need these edition open files/folders.
However, the catch is that I did not want to over-fill the main menu. I have created a submenu item which shows the other files/folders.

In addtion to above excelent answers from @ptim and @MoonLite, I have created a submenus which prevents overcrowding it with numerous entries. On windows the path is (when using custom scoop directory: C:\app_scoop\apps\sublime-text\current\Data\Packages\Default).

I have found out that you can acutally overload the menu. Just copy out the Main.sublime-menu; modify it with below code and place it into C:\app_scoop\apps\sublime-text\current\Data\Packages\Default and you will have custom menu with submenus.

I'm sharing a submenu way to view the files/folders (using Directories instead of Folders to have easier shortcut F... Files, D ... directories):

 {
        "caption": "File",
        "mnemonic": "F",
        "id": "file",
        "children":
        [
            { "command": "new_file", "caption": "New File", "mnemonic": "N" },

            { "command": "prompt_open_file", "caption": "Open File…", "mnemonic": "O", "platform": "!OSX" },
            { "command": "prompt_open_folder", "caption": "Open Folder…", "platform": "!OSX" },
            { "command": "prompt_open", "caption": "Open…", "platform": "OSX" },
            {
                "caption": "Open Recent",
                "mnemonic": "R",
                "children":
                [
                    { "command": "reopen_last_file", "caption": "Reopen Closed File" },
                    { "caption": "-" },
                    { "command": "open_recent_file", "args": {"index": 0 } },
                    { "command": "open_recent_file", "args": {"index": 1 } },
                    { "command": "open_recent_file", "args": {"index": 2 } },
                    { "command": "open_recent_file", "args": {"index": 3 } },
                    { "command": "open_recent_file", "args": {"index": 4 } },
                    { "command": "open_recent_file", "args": {"index": 5 } },
                    { "command": "open_recent_file", "args": {"index": 6 } },
                    { "command": "open_recent_file", "args": {"index": 7 } },
                    { "caption": "-" },
                    { "caption": "More Recent Files",
                      "mnemonic": "F",
                      "children":
                      [
                        { "command": "open_recent_file", "args": {"index": 8 } },
                        { "command": "open_recent_file", "args": {"index": 9 } },
                        { "command": "open_recent_file", "args": {"index": 10 } },
                        { "command": "open_recent_file", "args": {"index": 11 } },
                        { "command": "open_recent_file", "args": {"index": 12 } },
                        { "command": "open_recent_file", "args": {"index": 13 } },
                        { "command": "open_recent_file", "args": {"index": 14 } },
                        { "command": "open_recent_file", "args": {"index": 15 } },
                        { "command": "open_recent_file", "args": {"index": 16 } },
                        { "command": "open_recent_file", "args": {"index": 17 } },
                        { "command": "open_recent_file", "args": {"index": 18 } },
                        { "command": "open_recent_file", "args": {"index": 19 } },
                        { "command": "open_recent_file", "args": {"index": 20 } },
                      ]
                    },
                    { "caption": "-" },
                    { "command": "open_recent_folder", "args": {"index": 0 } },
                    { "command": "open_recent_folder", "args": {"index": 1 } },
                    { "command": "open_recent_folder", "args": {"index": 2 } },
                    { "command": "open_recent_folder", "args": {"index": 3 } },
                    { "command": "open_recent_folder", "args": {"index": 4 } },
                    { "command": "open_recent_folder", "args": {"index": 5 } },
                    { "command": "open_recent_folder", "args": {"index": 6 } },
                    { "command": "open_recent_folder", "args": {"index": 7 } },
                    { "caption": "-" },
                    { "caption": "More Recent Directories",
                      "mnemonic": "D",
                      "children":
                      [
                        { "command": "open_recent_folder", "args": {"index": 8 } },
                        { "command": "open_recent_folder", "args": {"index": 9 } },
                        { "command": "open_recent_folder", "args": {"index": 10 } },
                        { "command": "open_recent_folder", "args": {"index": 11 } },
                        { "command": "open_recent_folder", "args": {"index": 12 } },
                        { "command": "open_recent_folder", "args": {"index": 13 } },
                        { "command": "open_recent_folder", "args": {"index": 14 } },
                        { "command": "open_recent_folder", "args": {"index": 15 } },
                        { "command": "open_recent_folder", "args": {"index": 16 } },
                        { "command": "open_recent_folder", "args": {"index": 17 } },
                        { "command": "open_recent_folder", "args": {"index": 18 } },
                        { "command": "open_recent_folder", "args": {"index": 19 } },
                        { "command": "open_recent_folder", "args": {"index": 20 } },
                      ]
                    },
                    { "caption": "-" },
                    { "command": "clear_recent_files", "caption": "Clear Items" }
                ]
            },

... (continued)
tukan
  • 17,050
  • 1
  • 20
  • 48