Summary of steps to setup sublime for use with R, Python, Java and C.
For OS X, to work with files on the command line:
Then to open text files:
.profile. and add
export EDITOR='subl -w'. This will specify to use sublime for commands that prompt for input.
The command to install package control might change with later versions. See here.
To install package control for sublime open the console with
ctrl + (`) and paste the following python code:
command + shift + p (command palette) and open package control and install REPL.
To open an instance of python/r open the command palette and find SublimeREPL: Python or SublimeREPL: R. This will open a python/R console inside sublime.
It might be helpful to change the key bindings to send code to R/python code directly to the interpreter. Key bindings can be found using the command palette or under preferences.
The above code will send and execute a code selection, the entire file and a line of code respectively. It’s possible to send the code without executing by including
"action":"view_write" under args. Example:
Linking with R
Install R-box using command palette. REPL links sublime to R but the R-Box package also integrates knitr documents and Rcpp. R-Box allows sublime to send r code to the R-gui window directly.
Sublime has an extendable build system. It’s possible to compile a language with
command + b and compile and run a language with
command + shift + b. To add a new build system, go to tool > build system > new build system. The following will add C to the build system:
The following will add C to the build system and allow for both compile only and compile/run in a single key combination.
Sublime over SSh
Sublime has a feature to edit files on a remote server based on rmate; rmate provides similar ssh access for textmate. This feature requires the rsub plugin in sublime and requires a script on the server. It’s possible to use this even without sudo access on the server.
From textmate’s github repo download the rmate ruby script under bin/rmate – it might be helpful to rename the script to rsub for sublime. Put this on the server under
/usr/local/bin. Set the correct port under rsub settings in sublime. To test if this is correctly setup, SSH into the server using:
ssh -R 52698:localhost:52698 firstname.lastname@example.org. Then once on the server
rsub filename, this should open sublime on your local computer.
Quick summary here.