Sublime Forum

Altering default context menu

#1

Hi all.

I’m having trouble changing the default context menu. I am able to add items by adding
Context.sublime-menu
to the folder
%userprofile%\AppData\Roaming\Sublime Text 3\Packages\User
but I can’t find the actual default file that I can edit to change the current commands.

0 Likes

Is there a way to remove a default menu item with a plugin?
#2

The base Context.sublime-menu file is stored in the Default package, which is stored as a sublime-package file and isn’t visible in the Packages or Installed Packages directory because it ships with Sublime text. Modifying or overriding that file will alter the menu contents, while putting a similarly named file in any other Package directory will augment it instead.

To actually change the default, you can use PackageResourceViewer; select Package Resource Viewer: Open Resource from the command palette, then select the Default package and the Context.sublime-menu file. This will open up the packaged file for you, and when you save will automatically create a package override for the file.

From this point forward sublime will ignore the shipped version of the file and use your version as the base instead; other packages can still augment the menu as desired.

Note that you won’t get warned by Sublime if a future update makes modifications to the default context menu. Your override will be used unconditionally. In order to ensure that you get warned of potential future changes to the file you’re overriding, you can use OverrideAudit, which will warn you if the shipped file becomes newer than your override.

4 Likes

#3

Excellent, thanks for the detailed reply.

Everything working great. I noticed a Default folder was created with a new Context.sublime-menu file that I can now edit directly without PackageResourceViewer. I saw that referenced a lot in forum posts but was at a loss as to why I didn’t have that.

Thanks again!

0 Likes