Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

About the forward and backward a word behaviour in Emacs

Tags:

command

emacs

I don't know if there's something wrong with my settings but when I press M-f (forward a word) it doesn't matter where I am, it never place the cursor in the next word (just between words). This doesn't happen with M-b which place my cursor in the beginning of the previous word.

Is this a normal behavior? How do I place my cursor at the beginning of the following word?

like image 236
alexchenco Avatar asked Jan 16 '10 20:01

alexchenco


1 Answers

The macro solution described is a great way to get this behavior in a session, but it's a little inconvenient if that's the default behavior you want, since you have to define it every time you start emacs. If you want M-f to work like this all the time, you can define an elisp function and bind it to the key. Put this in your .emacs file:

(defun next-word (p)
   "Move point to the beginning of the next word, past any spaces"
   (interactive "d")
   (forward-word)
   (forward-word)
   (backward-word))
(global-set-key "\M-f" 'next-word)
like image 111
John Nienart Avatar answered Oct 01 '22 08:10

John Nienart