5

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?

2

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 ()
  (interactive)
  (save-excursion
    (goto-char (point-min))
    ;; start at line 2
    (forward-line 1)
    (while (progn
             (mc/create-fake-cursor-at-point)
             (eq (forward-line 2) 0))))
  (mc/maybe-multiple-cursors-mode))

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.