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-@ Commented 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. Commented Mar 4, 2015 at 15:26
  • How do I do this programatically? Commented 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. Commented Mar 4, 2015 at 15:28
  • M-- & 'C--`, does both set the same prefix arg? Commented 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. Commented Mar 4, 2015 at 16:10

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.