Ten Things the Emacs Social Science Starter Kit gives you

[This article was first published on R on kieranhealy.org , and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

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.

  1. 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-ring will 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/mark will bring up all the commands that match, and you can use C-s to 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.

  2. Use M-x without the Meta key Most Emacs commands are accesed either via C-x or M-x. As is standard, Meta is mapped to the Mac keyboard’s “Option” key. But you can also invoke M-x by doing C-x m, which means most things can get done using either C-x or C-x m. It’s a little more convenient.

  3. 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-r invokes rgrep, which will ask you for a search term and a file type. If you have Ack installed, you can do C-x C-a to search all files in your working directory for some term. You can also do M-x ack-same to search only in files of the same type as the current buffer.

  4. 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 M-x auto-complete-mode.

  5. 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 2 or 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 Shift and the arrow keys. C-c m “rotates” windows, e.g. by moving the left window to the right side and vice versa. C-c-<up> and C-c-<down> cycle through the window configurations you’ve created in the past. Shift-C-<left>, Shift-C-<right>, Shift-C-<up>, and Shift-C-<down> resize split windows a little bit at a time.

  6. 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-Enter vertically 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-Enter sends the current line over to R. Repeatedly hitting Shift-Enter in 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.

  7. 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-mode adds a highlight to the current line, so you know where you are.

  8. 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.

  9. 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-lines or select a region and try M-x mc/mark-all-in-region to search for a bit of text to replace on each line.

  10. Minimal Mode When working full screen, I like to make scroll bars and the dividing lines between windows more unobtrusive. M-x minimal-mode (or C-c s for 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.

To leave a comment for the author, please follow the link and comment on their blog: R on kieranhealy.org .

R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)