2

There is a very convenient function M-@ Mark-word.

However, I usually find my self typing things, than marking things backwards to copy it some place else.

Is there something equivalent for mark-word-backwards or would I have to write a script to manually mark and go backwards? If so, is there a recommended key sequence to map this to?

Thank you.

1
  • You could use a negative prefix argument: M-- M-@
    – legoscia
    Mar 4, 2015 at 15:24

1 Answer 1

5

Use a negative prefix argument to mark backwards, for example:

M-- M-@

Note that you can also mark a number of words forwards or backwards. For example, mark backwards four words:

M-- M-4 M-@

Note that by default Emacs binds the prefix keys with a variety of modifiers. This makes it easier to specify a prefix when you are holding down some combination of modifiers for whatever command you are about to call. For example, I often use the following to mark a sexp backwards:

C-M--C-M-SPC.

5
  • This seems to be what I was looking for. Mar 4, 2015 at 15:26
  • How do I do this programatically? Mar 4, 2015 at 15:26
  • 1
    Programatically you can pass an arugment to the mark-words function -- that is what happens with the prefix arg keys. So (mark-word -1) will mark backwards one word.
    – glucas
    Mar 4, 2015 at 15:28
  • M-- & 'C--`, does both set the same prefix arg?
    – Saravana
    Mar 4, 2015 at 16:07
  • Right. By default M-, C-, and C-M- are all configured to work as modifiers for a prefix argument (a digit or -). Of course many people (myself included) end up redefining some of those keys to do other things, but in a stock Emacs setup they are interchangeable.
    – glucas
    Mar 4, 2015 at 16:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.