If you haven't yet picked a Scala IDE to use, I would like to recommend the ENSIME mode for Emacs and other editors. You can find it at the following website:
Obviously installation instruction will be dependent on the kind of editor you are using. If using it with Emacs (a popular cross-platform editor), the installation process is described here. You can get Emacs from the Emacs website:
https://www.gnu.org/software/emacs/
There are a lot of books available on using it. It is completely open source and with ENSIME it makes probably the best open source IDE for Scala, in the author's opinion. After installing Emacs on your system, you can install ENSIME. To do this, first add the following lines to your .emacs
file, which (on Linux) usually resides in your home directory. If you are not using Linux, consult the Emacs documentation for where the .emacs
file is. The following code assumes a fairly recent version of Emacs. This was tested with Emacs 24:
(require 'package) (add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/")) (when (< emacs-major-version 24) (add-to-list 'package-archives '("gnu" . "http://elpa.gnu.org/packages/"))) (package-initialize) (require 'ensime) (add-hook 'scala-mode-hook 'ensime-scala-mode-hook)
After adding this and restarting Emacs, you need to actually install ENSIME, which is fortunately really simple. Just use the M-x package-install key combination, press Return, then enter ensime
, and press Return again. Note that M in Emacs stands for the Alt key. So the combination is Alt-x. However, it is customary to write it the way we did.
Scala integrates well with the SBT tool, which we will discuss in the next section. Instructions on how to integrate the two are given in it. Here we will just list some of the things that ENSIME can do for you to enable you to write code more efficiently and mistake-free. These include code completion, type inspection, automated refactoring, and code navigation. ENSIME will also highlight parts of your code that contain compilation errors. It is usually easy to tell from the markings where you went wrong.
The code completion feature will show you possible completions for the code you are currently typing. If it is a variable name, it will try to guess how to complete it so that you can enter it quickly. Also, you can press the Tab key after entering the object name and a dot (.). This will show you a list of all methods you can use for that object.
Type inspection allows you to see what will be the result of Scala's type inference mechanism. To see what type has been inferenced, simply use the C-c C-v i key combination. This means Ctrl-c Ctrl-v i in Emacs notation.
Automated refactoring features let you conveniently rename variables, without worrying that you may have forgotten some, and do other similar stuff. This is more useful for larger projects.
Code navigation features in ENSIME let you move around in the code by finding the definitions of symbols under the cursor. You can use M-. to jump to the definition of the object under the cursor.
The complete command reference for ENSIME can be found at:
https://github.com/ensime/ensime-emacs/wiki/Emacs-Command-Reference