I recently made some updates to the Emacs Social Science Starter Kit. I maintain the SSSK for my own convenience, but other people have found it useful as well. By now there are a lot of little bits and pieces in the kit, so I thought it might be useful to do a listicle highlighting some of the conveniences it offers. As a reminder, the motivation behind the kit was to allow researchers, faculty, and grad students working in the social sciences to get started with Emacs. The general principles the kit tries to facilitate are discussed in my (now slightly outdated) article on Choosing Your Workflow Applications.
Rather than try to cover all the many great features of every package the kit installs—all the products of a terrific amount of work by other people, and some of which, like AucTeX and ESS, are very large and sophisticated—I am just going to mention some of the useful things you might immediately use once you’ve installed the starter kit.
Ido-mode and Smex mean you don’t have to Memorize a Huge Battery of Shortcuts Like any powerful text editor, time-saving keyboard shortcuts are central to using Emacs efficiently. While it’s easy to grasp the general logic of Emacs key-chords, getting specific ones into your muscle memory takes longer, especially for features which you might not use all that often. In the interim, the SSSK sets up ido-mode and Smex, and together they allow you to search buffers, file names, and functions quickly and flexibly. They also remember what you’ve searched for before, so they are more likely to prompt you with the right option the next time. So, for example, if you want to browse the kill-ring (Emacs’s multi-item clipboard) but you don’t remember the keyboard shortcut, starting to type
M-x browse-kill-ringwill complete the command very quickly. If you can’t remember the command to insert multiple cursors in a region (see below), starting to type
M-x mc/markwill bring up all the commands that match, and you can use
C-sto cycle through the options. Thanks to ido-mode, search functionality for finding files, open buffers, functions, and other commands is very smart and flexible. If you partly remember the name you’re looking for, or type a shortened or partial version of it, it will likely be found, and it gets better the more you use it.
Use M-x without the Meta key Most Emacs commands are accesed either via
M-x. As is standard, Meta is mapped to the Mac keyboard’s “Option” key. But you can also invoke
C-x m, which means most things can get done using either
C-x m. It’s a little more convenient.
Search inside multiple files with rgrep or ack You can search for text inside files in your current directory (and recursively all directories underneath it) in one of two ways.
C-x C-rinvokes rgrep, which will ask you for a search term and a file type. If you have Ack installed, you can do
C-x C-ato search all files in your working directory for some term. You can also do
M-x ack-sameto search only in files of the same type as the current buffer.
Autocomplete text as you write Autocomplete mode is useful for completing functions in the scripting or programming languages it knows about (including R), and it can also be useful in long text documents. It’s turned off by default for most text modes (except org-mode) in the SSSK, but you can enable it in a buffer with
Quickly Resize, Rotate, and Cycle through Windows Early on when using Emacs you learn to split a frame into two or more windows with
C-x 3. As you work (e.g., with R code in the left-side buffer and an R session running in the right-side buffer), you often want to move the cursor to a different window, move buffers from one window to another, or cycle back and forth between different window configurations you’ve used. The starter kit lets you move the cursor between windows using
Shiftand the arrow keys.
C-c m“rotates” windows, e.g. by moving the left window to the right side and vice versa.
C-c-cycle through the window configurations you’ve created in the past.
Shift-C-resize split windows a little bit at a time.
Make Shift-Enter do a lot in ESS When working with R and ESS, if you open an R file in the main buffer then htting
Shift-Entervertically splits the window and starts R in the right-side buffer. If R is running and a region is highlighted, shift-enter sends the region over to R to be evaluated. If R is running and no region is highlighted,
Shift-Entersends the current line over to R. Repeatedly hitting
Shift-Enterin an R file steps through each line (sending it to R), skipping commented lines. The cursor is also moved down to the bottom of the R buffer after each evaluation.
Turn on Highline-mode when you need it Some people find it easier to edit code when they can see exactly where the cursor is on the screen.
M-x highline-modeadds a highlight to the current line, so you know where you are.
LaTeX Symbols display nicely in the buffer The kit includes
latex-pretty-symbols. When editing a text file, you can type TeX commands like \sigma and \gamma and they will display properly (as unicode symbols) right in the buffer. The LaTeX command is still there underneath.
Multiple Cursors One of the flagship features of Sublime Text 2, editing with multiple cursors can be a really useful dynamic alternative to search-and-replace when you want to make the same changes to a bunch of lines in a file. Thanks to Magnar Sveen, multiple cursor support is now available in Emacs and the SSSK installs the package. The easiest way to see it in action is to select a region and do
M-x mc/edit-beginning-of-linesor select a region and try
M-x mc/mark-all-in-regionto search for a bit of text to replace on each line.
Minimal Mode When working full screen, I like to make scroll bars and the dividing lines between windows more unobtrusive.
C-c sfor short) toggles them on and off.
There’s a lot more in the SSSK, from handy functions to a few themes (try
M-x load-theme solarized-dark or
zenburn) and you can browse the notes in the kit’s org files to learn more about what it sets up for you, and how to customize it to your own needs.