TextEditors and IDEs¶
There are many options for editors and IDEs (integrated development environments), and members of the lab have different preferences and configurations that work best for them. Familarity with one Unix/Linux based editor is important for interacting with remote servers. Locally on your own machines, we recommend a full featured IDE such as Atom or SublimeText 3 for writing code, quick text searching and processing with regular expressions, as well as other functionality provided by the many available plugins. Atom with the Hydrogen package is our top choice for running python code inline and can be used to supplement or replace Jupyter notebooks.
Text Editors¶
Text editors are often more lightweight without all of the functionality of full IDE. You will most often use them for working with code or text on a remote machine. There are several options but we highlight two that are common on Unix-based machines.
Nano¶
Super simple text editor that is lightweight and easy for beginners. It is installed on most unix / linux based systems by default. Nano does not include many of the useful features of more complicated text editors or IDEs so it is not recommended to use beyond quick file manipulation tasks. Launch with $ nano filename.txt.
Vim¶
Vim is a powerful text editor that is guaranteed to exist on all unix systems. The downside is that there is a bit of a learning curve even for basic file manipulation. This initial learning curve is perhaps why Vim can sometimes be polarizing among programmers—a perhaps helpful analogy is that Vim is like a manual transmission automobile—some people may find the experience of learning and discovering more capabilities of Vim rewarding, while others may think it's a waste of time, especially when you can go straight for the automatic transmission options. As with the car analogy, it is probably worth learning enough to do some simple tasks (i.e., be able to drive everywhere), but whether or not to spend time beyond that is up to individual preferences.
Vim comes with its own 'tutor' for basic commands, which you can access by running vimtutor in your shell, and there are many more resources online. Here is one example, and there is even a game for learning vim.
Default Vim behavior, appearance, and plugins are configured in the .vimrc file. We provide an example for those who want to start with some useful configurations (and comments describing what each line's purpose is), but there are endless possibilities—basically almost anything is customizable.
To use this particular .vimrc, here are the steps to follow.
- Place this file in your home directory:
~/.vimrc. - To enable the python autocomplete and linter, a few python packages need to be installed. If neither Miniconda nor Anaconda are installed, check out the Conda section below, then install the relevant packages using the following command in your default conda environment:
$ conda install autopep8 flake8 pylint jedi - When you open your
.vimrcfile for the first time ($ vi ~/.vimrc), it will automatically download the vim-plug plugin manager, and install the plugins specified in the file. You will also see some warnings / errors for certain plugin settings, since they haven't been installed yet. Next time you open Vim, everything should be ready to go.
IDEs¶
Atom¶
Atom is an IDE created by developers at github, and thus has many useful default features for interacting with GitHub repositories (e.g., make commits, compare changes, push, navigate pull requests). Atom is already installed on mochi and risotto, and you can connect to it over X11. On macs, you will have to do some configuring to set up X11 to connect. These are the basic steps to get it running:
Info
- install homebrew (if not currently installed)
- open terminal to install xquartz
brew cask install xquartz - edit the
sshd_configfile,$ sudo vim /etc/ssh/sshd_configadding the following lines:X11Forwarding yes X11DisplayOffset 10 X11UseLocalhost yes $ launchctl load -w /Library/LaunchAgents/org.macosforge.xquartz.startx.plist- restart computer
Note
Homebrew is a very useful package manager for macs that allows you to easily install common linux packages (e.g., wget). Regardless of whether or not you decide to use XQuartz, if you have a mac, it is recommended that you install it.
XQuartz, the handler for X11, on macs, is kind of clunky. Another way to edit files on the server using Atom is to connect remotely using the remote-atom package. In this case, you install the Atom application as well as the package locally then set up rmate on the remote server. Because this process is similar for both SublimeText and Atom, we have a separate section below covering how to set up rmate on the server.
Of course, you can also develop your code locally and simply commit to GitHub and use the same repo for running on the server. For some projects, such as developing web servers, this workflow is indeed the most convenient. In practice, we have found that, for example, with projects that involve interacting with many large data files and/or resources that only reside on the server, there can be slightly more friction at times.
As mentioned already, a very useful Atom package to reduce this friction is Hydrogen, which allows you to develop code locally, but attach a remote Jupyter kernel. Once you set up the remote kernel on our servers, this means that, like Jupyter notebooks, you can easily run your python (or any other language that supports Jupyter kernels) commands inline (including plots) and interact with the data on servers within your local Atom instance.
Whichever workflow you end up settling on, just be sure to still commit changes regularly to GitHub!
PyCharm¶
PyCharm is a sophisticated IDE designed specifically for python development. It is a bulkier app, but has lots of functionality built in (e.g., direct access to terminal, management of virtual environments, python console, managing ssh connections with the remote servers, editing remote files, etc.). It might take a bit more time to set up than some of the other options, but it is extremely powerful for managing large python projects. Using your .edu email address, you can get a free license to their professional edition.
Sublime Text 3¶
Sublime Text is similar to Atom and has many of the similar packages, linters, and autocomplete functionality. Previously, the major advantage to Sublime Text over Atom was its speed when opening, editing, and searching large files. Newer releases of Atom are closing the gap. You can also configure remote file editing in SublimeText by installing the rsub package and installing rmate as described below.
Rmate¶
Rmate is a feature first implemented in an older IDE called TextMate. Rmate is essentially a lightweight script that sends remote files over a specific SSH port, allows you to edit them locally, and sends changes back to the remote file on save. It is really useful if you want to use a locally installed IDE to edit files stored on our servers without mounting a remote directory. There are many implementations of rmate. The remote-atom package has a good collection of implementations to install and a great overview of how to run rmate to edit files. The only addition is that you may have to add rmate to your path to be able to call rmate filename.txt without the whole path to the rmate executable.