prefix arguments

You can jump to the next line in emacs with C-n ('next-line'). However, how can we specify that we want to jump to the nth next (or previous) line? Or, more in general, how can we specify a (numerical) argument to an interactive function that support them?

The answer is that you can provide prefix-arguments to such functions; this can be done in two ways:


  • positive numeric arguments can be specified with M-<number>; that is, to use 5 as the prefix argument, you'd type M-5;
  • any numeric argument can be specified using C-u; so to set -3 as the prefix argument, you'd type C-u -3. Some functions also take C-u as a kind of boolean parameter; you set the parameter by specifying C-u without any parameter.

Using this, we can jump to the fifth next line with M-5 C-n, and to the third previous line with C-u -3 C-n. For details, see the emacs manual, and the documentation for the specific function (use M-x describe-function or C-h f).

Note: after ten years of using emacs, I discovered the M-<number> notation only when writing this entry...

No comments:

Post a Comment

Followers

Popular Posts