If you’re familiar with my development styles, you know that I am very against using IDE applications because of their sluggishness. Everyone will have their own opinions, but I much prefer Sublime Text over Eclipse for all development. Lucky for us, there is an awesome package for us called MavensMate, that lets us do Apex coding directly in Sublime Text.
At the time of writing this article, MavensMate only supports Sublime Text 3 which is currently still in beta. If you don’t already have it installed, download it and proceed to the next step.
You’ll need to install Package Control for Sublime Text in order to install the MavensMate package. This can be done by running the following inside the Sublime console:
import urllib.request,os,hashlib; h = '7183a2d3e96f11eeadd761d777e62404' + 'e330c659d4bb41d3bdf022e94cab3cd0'; pf = 'Package Control.sublime-package'; ipp = sublime.installed_packages_path(); urllib.request.install_opener( urllib.request.build_opener( urllib.request.ProxyHandler()) ); by = urllib.request.urlopen( 'http://sublime.wbond.net/' + pf.replace(' ', '%20')).read(); dh = hashlib.sha256(by).hexdigest(); print('Error validating download (got %s instead of %s), please try manual install' % (dh, h)) if dh != h else open(os.path.join( ipp, pf), 'wb' ).write(by)
If you don’t know how to find the console, you can press ctrl+` or go to View -> Show Console in the toolbar. Per the Package Control documentation, you should use the code found on the site as it changes for every release.
With Package Control installed, press Ctrl + Shift + P or go to Tools -> Command Palette in the toolbar. Type the following to install a package:
Package Control: Install Package
When a list of packages become presented, type MavensMate to install the package.
We are almost completely set up. With MavensMate installed, you should now see a new toolbar item for the package. Choose MavensMate -> Settings -> User from the toolbar and find mm_workspace near the top. Type a path that exists on your machine and this is where all new Apex projects will reside. If you’re on Windows, you must escape the slashes. So your workspace may look something like C:\\Users\\nraboy.
Restart Sublime Text for all the changes to take affect.
With Sublime Text open, choose MavensMate -> Project -> New Project… from the toolbar and it should open a web page. If it does not, it is because you don’t have Chrome or another web browser as the default application for opening HTML files.
Choose a name for your new project and provide your Salesforce username and password. When you’ve done this, click the Create Project button to complete the process.
This should result in Sublime Text creating a new coding work space for you.
At this point it is up to you what you want to do. You can create classes, test scripts, deploy to production, etc. I, for example, find the script editor found in Apex Scripting -> Execute Apex… very useful as it is a quick and simple playground for testing my code.