Search code examples
sublimetext3menubar

Sublime Text 3- Main Menu Bar Customization


I just installed Sublime Text 3 on my Windows system and like how it works and all the plugins that come with it, I added some customization to my main context menu, so that I can call the commands directly.

I added a caption with a whole bunch of empty spaces in it to look like it is on the second row, but when you hover it shows highlighting which looks clunky and shows on just one line when you maximize the window.

Is there a way to customize it where the added items on the menubar are stored on a separate row from the File,Edit,Selection,Find... menus without having to add a caption? The overall goal is to make it similar to Notepad++ toolbar.

Notepad ++ Toolbar: enter image description here

Menu Code:

[
    {
        "id": "help"
    },
    {
        "id": "folders", "caption": 
            "                                                                                                                                                                       "
    },
    {
        "id": "folders", "caption": 
            "Shortcuts:"
    },
    {
        "command": "prompt_open_folder",
        "caption": "📁 Open Folder"},
    {
        "command": "new_file",
        "caption": "🗋 New File"},
    {
        "command": "save",
        "caption": "💾 Save"},
    {
        "command": "show_panel", 
        "args": {
            "panel": "find", "reverse": false 
        },
        "caption": "🔎 Find"
    },
    {
        "command": "show_panel", 
        "args": {
            "panel": "replace", "reverse": false 
        },
        "caption": "🔍 Replace"
    },
    {
        "command": "build",
        "caption": "▶ Build"},
    {
        "command": "expand_selection",
        "args": {
            "to": "scope"
        },
        "caption": "♒ Expand"
    },
    {
        "command": "fold_by_level", 
        "args": {
            "level": 1},
        "caption": "⮝ Fold"
    },
    {
        "command": "unfold_all",
        "caption": "⮟ Un-Fold"
    },
    {
        "command": "open_terminal",
        "caption": "🗔 Terminal"
    }
]

Desired result: enter image description here


Solution

  • Menus are displayed in Sublime by native OS methods (or in the case of Linux, via GTK3). As far as I'm aware there is no direct way to break the main menu into lines like you want other than by using the mechanism you're already using.

    That said since the menus are displayed natively, it's theoretically possible that if there is a special character you can add to a menu caption for your OS that would make it break the menu, that would work.

    On Linux for example your menu from above doesn't wrap and just makes the window large enough to fit the menu without a wrap. Similarly adding \r or \n to get a line break breaks the caption, but within the layout of it's own item and not in the menu as a whole.

    Generally the UI of Sublime is intended to be as unobtrusive as possible to make as much room as possible for text, which is why the find and replace actions are small panels and not floating windows and why the toolbar that used to exist was removed in 2009.