Sublime Forum

Add "Delete" command to context menu

#1

I want to add a simple “Delete” option to the right click context menu in Sublime Text 3. This would be an option in addition to Cut or Copy.

Doing some research, I found http://www.sublimetext.com/docs/menus but feel it isn’t complete. To test things, I copy and pasted the xml sample in Sublime and saved it under .Packages/Default/Context.sublime-menu but it wiped out everything aside from menu entries added by plug-ins.

Further google searching did not yield other sources for a more detailed entry level how-to. Is there one somebody can share?

Thanks and have a great day!

0 Likes

#2

create file /User/menus/Context.sublime-menu

with content

{
	"caption": "Delete",
	"command": "delete"
}

]

The documentation you are looking is for ST1, look here sublimetext.com/support

0 Likes

#3

Thanks for the help tito but it didn’t work. I saved it under the path and name you gave and then under /User/Context.sublime-menu. In neither instance did the item appear in the context menu when a right-click was performed. Further research into commands for keyboard mapping and I don’t see one for simply delete

0 Likes

#4
  1. Main menu bar -> Browse Packages (this should open in explorer/finder/whatever the folder of the packages)
  2. Create or enter to the folder named “User”
  3. There create file “Context.sublime-menu”
  4. Add to that file the content of the previous post.
  5. It should add the item, even if “disabled/greyed out” because the command “delete” I think does not exists. But at least is progress, we should later correct the command name and maybe parameters.
0 Likes

#5

I have it working now but it is greyed out. So we need to work on the commands next.

Thank you for your patience, Tito. It is very much appreciated.

0 Likes

#6

Open Preferences > Key Bindings - Default to see an incomplete list of commands and copy from one that does what you need. E.g.

{ "command": "right_delete", "caption":"delete" }, ]

0 Likes

#7

If you mean to delete the file AND you have SideBarEnhancements package installed (which will play nicely on the delete operation), you can use the following command:

{
	"command": "side_bar_delete",
	"args": {
		"paths": ]
	},
	"caption": "Delete File"
}

if you dont use SideBarEnhancements Im not sure how to tell the command to delete current file.

0 Likes

#8

@tito and @steveh4133

Thank you for the help. The context command I wanted to add was to delete a block of text selected just before a mouse right-click.

Please pardon the delay posting this. For a few days I could not call up this site in my browser and then became busy with other projects.

0 Likes

#9

Follow the steps @steveh4133 provided.

If you want to get fancy and have the command in the same region as the other clipboard commands, use this:


	{"id": "clipboard"},
	{"caption": "Delete", "command": "right_delete"}
]
0 Likes