2

I have some function like this:

(defun some-function ()
  (interactive)
  (while (re-search-forward "^(def" nil t)
    (replace-match "hello")
    ;; -- Go to next line and do something here
    ))

Now once the regexp matches on and replaces the word, I want to go to the next line and do some text manipulation in the second line (like inserting some characters at the start of the line). How would I do that ?

  • (forward-line 1)? – Kaushal Modi May 29 '15 at 21:39
  • @kaushalmodi Facepalm! Can you post that as an answer ? – Sibi May 29 '15 at 21:42
3

(forward-line 1) will take the point to the next line.

You can learn more about that and other motion commands from here.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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