I use a lot multiple cursor and sometimes I have to select some words which are off the screen, in sublime text I do not encounter any problem, I can just scroll and continue selecting words. This, incredibly, seems not possible in emacs! When I scroll the previous cursors get messed up. You can see this behaviour in the gif I have uploaded. This may help: Let Emacs move the cursor off-screen

Sublime Text behaviour:

Sublime Text behaviour

emacs behaviour:

emacs behaviour

  • 1
    The point (cursor) in Emacs is always on the visible portion of the screen. If you scroll the buffer far enough that point moves off the screen, it is automatically 'bumped' such that it will remain in the visible section of the buffer. The answers to the question you link to suggest some work-arounds. However, as I understand it this behaviour is pretty fundamental in Emacs, without a simple fix. I don't think there is a straightforward solution for your use-case. – Tyler Aug 22 '17 at 13:40
  • @Tyler this is a very bad news. It is one of the key feature of most modern editors and so I think it is a bad strike for emacs. – Nisba Aug 22 '17 at 14:24
  • Are you using this package: github.com/magnars/multiple-cursors.el ? See the end of this video: emacsrocks.com/e13.html – eflanigan00 Aug 22 '17 at 14:40
  • 1
    @Nisba understood. I haven't used other editors much, so don't miss this. You can scroll from one multiple-cursor selection to the next via C-v and M-v, or display just the selected lines with C-', which may help a little. – Tyler Aug 22 '17 at 14:49
  • Please @Tyler at least add this as a answer! Solved my problem. Is not ap properly solution, but is indeed a great workaround (and I saw the expected use case with multiple-cursors.el) – Manoel Vilela Oct 18 '17 at 22:57

In Emacs, the points (cursor) is always on the visible portion of the file you are visiting. This coded deep down in the guts of the program, so you won't be able to change this without a great deal of effort.

As a work around, you can use C-v and M-v to navigate back and forth from one multiple-cursor selection to the next. You can also hide all lines that don't contain a multiple cursor selection with C-'. In order for this last keybinding to work, you need to make sure mc-hide-unmatched-lines-mode is enabled, ie., put the following in your config:

(require 'mc-hide-unmatched-lines-mode)
  • My C-' is undefined, what is yours bound to? – Nisba Oct 19 '17 at 17:23
  • @nisba see update – Tyler Oct 19 '17 at 18:33
  • It is a huge improvement and I find it very useful most of the times, but sometimes even hiding the unmatched lines, the matches don't fit the screen. I view this like a very very nice workaround, but I hope that one day someone will come out with a complete solution! – Nisba Oct 28 '17 at 6:38

Call the mc-mark-next-like-this-then-cycle-forward instead of mc/mark-next-like-this to auto scroll along with the selection.

(defun mc-mark-next-like-this-then-cycle-forward (arg)
  "Mark next like this then cycle forward, take interactive ARG."
  (interactive "p")
  (call-interactively 'mc/mark-next-like-this)
  (call-interactively 'mc/cycle-forward))

(defun mc-skip-to-next-like-this-then-cycle-forward (arg)
  "Skip to next like this then cycle forward, take interactive ARG."
  (interactive "p")
  (call-interactively 'mc/cycle-backward)
  (call-interactively 'mc/skip-to-next-like-this)
  (call-interactively 'mc/cycle-forward))

(defun mc-mark-previous-like-this-then-cycle-backward (arg)
  "Mark previous like this then cycle backward take interactive ARG."
  (interactive "p")
  (call-interactively 'mc/mark-previous-like-this)
  (call-interactively 'mc/cycle-backward))

(defun mc-skip-to-previous-like-this-then-cycle-backward (arg)
  "Skip to previous like this then cycle backward take interactive ARG."
  (interactive "p")
  (call-interactively 'mc/cycle-forward)
  (call-interactively 'mc/skip-to-previous-like-this)
  (call-interactively 'mc/cycle-backward))

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.