Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

In emacs there are the functions forward-word and backward-word. Are there also functions which move the point to the next/last whitespace?

share|improve this question
    
Isn't this for a lot of cases equivalent? What is the use case there a different functionality is needed? –  H.-Dirk Schmitt Oct 31 '12 at 15:57
    
For example if a have a generalized word like \a_command_with_special-characters –  Julia Oct 31 '12 at 16:21

2 Answers 2

up vote 6 down vote accepted

You can modify the syntactical properties of characters using the modify-syntax-entry function (C-h f modify-syntax-entry in emacs for more info):

For instance, if you are writing .tex documents, you might add the following to your .emacs:

(add-hook
 'TeX-mode-hook
 '(lambda ()
    (modify-syntax-entry ?_ "w")
    (modify-syntax-entry ?- "w")
))

This tells emacs to treat _ and - as "word" characters when you are in TeX mode, thus forward-word and backward-word will do what you want.

share|improve this answer

Use forward-whitespace to advance by spaces, tabs or newlines. Multiple spaces are treated as one delimiter. With a negative argument, go backwards by that number of whitespaces.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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