7

I need to rename a class in MavensMate. I ended up creating a new class and copying the code. Is there another way?

2 Answers 2

6

Yes there is a way. While inside sublime:

  1. Edit the class name you wanted to edit
  2. Save it locally
  3. Compile the file you just saved
  4. At the menu bar, click Mavensmate > Project > Clean project (please see image below)

Image sublime text mavensmate

After the cleaning process, you'll see that the old class file is still open in sublime, the class name already changed but the filename is still the same, and is not saved. This is normal don't worry. Just discard this file. After discarding, search for the newly created file (one way to do this is to press CTRL+P, then type the new class name. It should be there and you should be able to choose it), choose it, and the new newly renamed class should open up. After the class opened up, you will see that its file name is the same as the class name.

If you're still having doubts if the class really got renamed, log in to your SFDC environment and search in Objects > Apex Classes. You'll find out that the old name is not there anymore, but the new name is.

Cheers!

Sam


Update 2017-03

I found out that after step 4, you have to add a few more steps. Take note that the steps below, I believe, applies to those Mavensmate users of version >= 7.0.2, and the new mavensmate app version >= 0.0.10.

  1. Click Mavensmate > Project > Edit Project...
  2. After the mavensmate app opens, go to the Project Metadata tab
  3. Search for a class with a name that's same with the name you used in your renaming awhile ago.
  4. Tick its checkbox
  5. Click the blue Update Project button at the top right area.

That's it.

4

Sadly, there isn't really. The only alternative is renaming classes/triggers by going into Salesforce, but this isn't any more convenient than creating a new class and deleting the old one. https://developer.salesforce.com/page/Miscellaneous

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .