如何在Sublime Text 3中增加最近文件的数量?

kin*_*ana 48 sublimetext3

是否可以增加Sublime Text 3(Ubuntu)中文件 - >打开最近菜单中出现的最近文件的数量?

我已经阅读过Sublime Text 2中最近项目的增加数量?

我在我的电脑上找不到这个〜/ Library文件夹.我可以找到〜/ .config/sublime-text-3/Packages但是里面没有"Default"子文件夹.

pti*_*tim 68

至少在OSX上,Default.sublime-package在应用程序本身中:/Applications/Sublime Text.app/Contents/MacOS/Packages/Default.sublime-package.

要轻松编辑配置而不在更新时覆盖更改,您需要在Packages目录中使用Main.sublime-menu的副本 ~/Library/Application Support/Sublime Text 3/Packages/Default/Main.sublime-menu

实现这些更改的最简单方法是通过skuroda 安装优秀的PackageResourceViewer(使用Package Control),然后:

  1. 命令+ Shift + P
  2. 输入'resource'并选择' PackageResourceViewer:Open resource '
  3. 你看到一个可用包列表:选择' 默认 '
  4. 选择' Main.sublime-menu '
  5. PackageResourceViewer现在可以复制Main.sublime-menu到正确的位置并打开新文件进行编辑.
  6. 根据Rufus_12的回答,改变出现的数量open_recent_folderopen_recent_file语句,每次都增加索引.

    { "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... 
    
    Run Code Online (Sandbox Code Playgroud)

  • 对于那些想要增加最近项目数量的人,请遵循上面相同的说明,但是使用`{"命令":"open_recent_project_or_workspace","args":{"index":0}},` - 在同一个Main中.sublime-menu(谢谢@chuckf) (6认同)
  • 这也适用于项目菜单中的最近文件.在Main.sublime菜单中查找"项目"部分. (3认同)
  • 比接受的答案容易得多 (2认同)
  • PackageResourceViewer有用且容易。ty (2认同)

Sam*_*Sam 25

Linux上的Sublime Text 3中的Default包存储在(假设您使用.deb安装程序)/opt/sublime_text/Packages/Default.sublime-package.

Default.sublime-package是一个ZIP文件,如果您将其打开并从中提取Main.sublime-menu文件~/.config/sublime-text-3/Packages/Default/Main.sublime-menu,则可以按照链接的答案描述的方式进行编辑.

或者运行以下命令,这些命令将创建Default目录并将Main.sublime-menu文件解压缩到其中:

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
Run Code Online (Sandbox Code Playgroud)

  • 在Windows上:打开`%appdata%\ Sublime Text 3\Packages`,添加`Default`目录.按照答案中的说明粘贴已编辑的Main.sublime菜单.(是的,您可以将DOS env vars粘贴到文件浏览器栏和运行...框中.) (2认同)

Jam*_*oss 15

将其添加Main.sublime-menu到您的%APPDATA%\Sublime Text 3\Packages\User文件夹中.您将看到一个名为Open Recent More的已添加文件菜单子项,为您提供下一个相同数量的最近文件/文件夹.(但是,只有我可以将它放在我想要的菜单中.)

[
    {
        "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": "-" }
                ]
            }
        ]
    }
]
Run Code Online (Sandbox Code Playgroud)

  • 最佳答案,因为它是更新证明:http://stackoverflow.com/a/37060993/4934640 (2认同)

A W*_*per 10

对于那些懒得复制和粘贴的人,然后更改数字,这里有50个.

                { "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 } },
Run Code Online (Sandbox Code Playgroud)


Ruf*_*_12 6

在Windows 7或8上,您:

  1. 在ZIP /存档实用程序中打开以下文件:
    C:\Program Files\Sublime Text 3\Packages\Default.sublime-package

  2. 仅将文件解压缩Main.sublime-menu为:(
    %APPDATA%\Sublime Text 3\Packages\Default
    必要时创建文件夹)

    该文件夹也称为:
    C:\Users\YourUsername\AppData\Roaming\Sublime Text 3\Packages\Default

  3. 打开Main.sublime-menu(刚刚提取的JSON文件)并更改显示的open_recent_folderopen_recent_file语句数,每次都增加索引.

        { "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...
    
    Run Code Online (Sandbox Code Playgroud)
  4. 点击保存,菜单应立即更新.:-)

您甚至可以将最近的文件/文件夹列表移动到根"文件"菜单中,以便于访问.


Moo*_*ite 5

我发现你实际上并不需要覆盖主菜单
只需添加您自己的菜单,该菜单将出现在最后。

创建这个新文件(我在 Linux 中的 Sublime Text 3 中的路径):
~/.config/sublime-text-3/Packages/User/Main.sublime-menu

在该文件中放置类似于 OdatNurd 之前答案的内容;

(我将相同的内容复制粘贴到文件中:
Context.sublime-menu
Side Bar.sublime-menu
以在那里显示相同的子菜单)


我只是用我自己的首字母“elm”制作了自己的子菜单,并将我个人使用的所有内容与各种“子”子树放在一起。

作为奖励,它会自动显示其后面相同命令的键盘快捷键
因此我也用它来提醒我不经常使用并忘记键盘快捷键的操作。


这适用于 Sublime Text 3
但也许有人可以测试这是否也适用于 Sublime Text 2 ?


我的文件看起来像这样:(
还添加了一些更多的想法(除了大量最近的文件之外)以获取灵感)

[
    {
        "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.
        ],
    },
]
Run Code Online (Sandbox Code Playgroud)

对于最近的文件来说有点题外话,但我认为这种方法还可以同时提高其他可用性和可维护性方面:)