5

What is the easiest way to skip forward to the first whitespace character after the current cursor? I used to do it just by searching for a space (when I knew there was one there), but now that seems to behave like forward-whitespace (not sure when this behavior switched, maybe when I transitioned to emacs 24. This is a function I need all the time when defining macros interactively.

Fwiw, forward-whitespace doesn't work for me because it skips to the last whitespace character in the first block of whitespace after the current cursor.

1 Answer 1

6

You can use skip-syntax-forward to skip non-whitespace. Docstring:

(skip-syntax-forward SYNTAX &optional LIM)

Move point forward across chars in specified syntax classes. SYNTAX is a string of syntax code characters. Stop before a char whose syntax is not in SYNTAX, or at position LIM. If SYNTAX starts with ^, skip characters whose syntax is NOT in SYNTAX. This function returns the distance traveled, either zero or positive.

If you want to use it interactively, you can wrap it in an interactive command:

(defun skip-to-next-whitespace () "Move point forward to next whitespace character." (interactive) (skip-syntax-forward "^\s")) 

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.