Emacs: Pasting with the mouse without moving the point – mouse-yank-at-point
Posted: - Modified: | emacsW- has been taking notes in Org Mode in Emacs, despite being a long-time Vim user. He likes org-indent’s virtual spaces over the way the Vim plugin for Org inserts actual spaces, and evil-mode provides a reasonable compromise in terms of keyboard shortcuts. I have been successfully resisting the urge to overwhelm him with tips. :)
He mentioned that he was thinking of going back to Vim because of one little thing he couldn’t get used to: mouse pasting behaviour. In vim in a Linux console, pasting with middle-click puts the text where the point is, no matter where you click. In Emacs in a GUI, middle-clicking moves the point and then pastes, so you have to be more careful about clicking where you want the text to go. I hardly ever use the mouse to paste, since C-y is more convenient for me, but everyone’s got their own workflow.
To make sure he didn’t feel any pressure from me to continue with Emacs, I nodded and suggested a few note-taking things he might try if he went back to the Vim world, like using pandoc to convert his Org Mode notes to Markdown. But Org Mode is awesome, so out of curiosity, I searched for “emacs don’t move point middle click”, which led me to a StackExchange answer, which had the exact thing we needed. W- added the following line to his ~/.emacs.d/init.el
:
(setq mouse-yank-at-point t)
Now middle-clicking pastes at the current location instead of moving it. Yay!
I think it’s awesome that at some point, someone decided to make that configurable, and someone asked about it and someone else answered, and all that can be found with the words I used. Yay community!
5 comments
hmelman
2017-04-04T20:01:39ZMore emacsy ways to find this would be:
1. use apropos searching for mouse or yank or point
2. look in the manual (it's indexed under yank and mouse and in the Mouse Commands section)
3. look in the Mouse group in customize.
I'm happy that web searches now show lots of emacs tricks, but I learned from using emacs itself and I feel like lots of people don't know how to do this. One of the things that's great about emacs is that it's self-documenting.
sachac
2017-04-07T14:28:59ZThanks for sharing those tips! =) I tend to go to the web first because of the fuzziness of searching, but it is so nice to have all sorts of ways to discover things from within Emacs too.
Mike F
2017-04-05T13:38:45ZGreat tip!!
Aerys B.
2017-04-06T08:39:17ZThat's an excellent end to the story.
Cev Ing
2020-07-20T10:22:15Z+1