How to increase number of recent files in Sublime Text 3?

Viewed 10730

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.

7 Answers

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 :)

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)
Related