How can I put a cursor (with multiple-cursors) in the beginning of every even line in emacs? Can I use the regular expression .*\n.*\n?


This function will add a cursor at every even-numbered line. It basically goes to line 2, and starts adding cursors every 2 lines until the end of buffer.

(defun mc/mark-even-lines ()
    (goto-char (point-min))
    ;; start at line 2
    (forward-line 1)
    (while (progn
             (eq (forward-line 2) 0))))

This is based on the implementation of mc/toggle-cursor-on-click from the Multiple Cursors package.

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.