This section is entirely optional. You’ve learned a few interesting tricks in this lab, and perhaps you’re wondering how you can do them in Emacs, which you may be a little more familiar with at present. This section is aimed at addressing that desire, albeit very briefly.
To process selected text, such as a
shell-command fragment, and replace it with its output,
use C-u M-|. If you use just
M-|, the results will be shown in a new
buffer. Similar to that is C-c M-!, which you
simply give a shell-command, and it will input the command’s
output into your document.
Global search and replace, with
confirmation, can be very easily achieved with
M-%. If you want to use a regular expression
instead, use C-M-%. If nothing is selected, it
operates from the current point to the end of the buffer.
Vim’s modelines are referred
to as “file variables” in Emacs, and can be specified alongside
Vim modelines. For further help, you can use the menu entry Help > Search
Documentation > Look up Subject in User Manual... >
file variables. Here is an example showing
both Vim and Emacs:
/* vim: softtabstop=4 shiftwidth=4 expandtab
*/
#include <stdio.h>
int main(int argc, char *argv[]) {
puts("Hello, world!");
}
/*
Local Variables:
mode:c
c-basic-offset:4
compile-command: "make hello CC='gcc -std=c99' CFLAGS='-O2 -Wall -Werror'"
End:
*/However, for stylistic sort of settings that generally get
applied to multiple files, it can be better to put such material
into a directory
variable instead, which goes into a file
.dir-locals.el.