Move point to where you click (
Activate the region around the text selected by dragging, and put the text in the primary selection (
Move point to where you click, and insert the contents of the primary selection there (
If the region is active, move the nearer end of the region to the click position; otherwise, set mark at the current value of point and point at the click position. Save the resulting region in the kill ring; on a second click, kill it (
Activate a rectangular region around the text selected by dragging. See Rectangles.
The most basic mouse command is
mouse-set-point, which is invoked by clicking with the left mouse button,
mouse-1, in the text area of a window. This moves point to the position where you clicked. If that window was not the selected window, it becomes the selected window. You can also activate a region by double-clicking
mouse-1 (see Word and Line Mouse).
Normally, if the frame you clicked in was not the selected frame, it is made the selected frame, in addition to selecting the window and setting the cursor. On the X Window System, you can change this by setting the variable
t. In that case, the initial click on an unselected frame just selects the frame, without doing anything else; clicking again selects the window and sets the cursor position.
mouse-1 and dragging the mouse over a stretch of text activates the region around that text (
mouse-set-region), placing the mark where you started holding down the mouse button, and point where you release it (see Mark). In addition, the text in the region becomes the primary selection (see Primary Selection).
If you change the variable
mouse-drag-copy-region to a non-
nil value, dragging the mouse over a stretch of text also adds the text to the kill ring. The default is
If you move the mouse off the top or bottom of the window while dragging, the window scrolls at a steady rate until you move the mouse back into the window. This way, you can select regions that don’t fit entirely on the screen. The number of lines scrolled per step depends on how far away from the window edge the mouse has gone; the variable
mouse-scroll-min-lines specifies a minimum step size.
Clicking with the middle mouse button,
mouse-2, moves point to the position where you clicked and inserts the contents of the primary selection (
mouse-yank-primary). See Primary Selection. This behavior is consistent with other X applications. Alternatively, you can rebind
mouse-yank-at-click, which performs a yank at the position you click.
If you change the variable
mouse-yank-at-point to a non-
mouse-2 does not move point; it inserts the text at point, regardless of where you clicked or even which of the frame’s windows you clicked on. This variable affects both
Clicking with the right mouse button,
mouse-3, runs the command
mouse-save-then-kill. This performs several actions depending on where you click and the status of the region:
- If no region is active, clicking
mouse-3activates the region, placing the mark where point was and point at the clicked position.
- If a region is active, clicking
mouse-3adjusts the nearer end of the region by moving it to the clicked position. The adjusted region’s text is copied to the kill ring; if the text in the original region was already on the kill ring, it replaces it there.
- If you originally specified the region using a double or triple
mouse-1, so that the region is defined to consist of entire words or lines (see Word and Line Mouse), then adjusting the region with
mouse-3also proceeds by entire words or lines.
- If you use
mouse-3a second time consecutively, at the same place, that kills the region already selected. Thus, the simplest way to kill text with the mouse is to click
mouse-1at one end, then click
mouse-3twice at the other end. To copy the text into the kill ring without deleting it from the buffer, press
mouse-3just once—or just drag across the text with
mouse-1. Then you can copy it elsewhere by yanking it.
mouse-save-then-kill command also obeys the variable
mouse-drag-copy-region (described above). If the value is non-
nil, then whenever the command sets or adjusts the active region, the text in the region is also added to the kill ring. If the latest kill ring entry had been added the same way, that entry is replaced rather than making a new entry.
Whenever you set the region using any of the mouse commands described above, the mark will be deactivated by any subsequent unshifted cursor motion command, in addition to the usual ways of deactivating the mark. See Shift Selection.
Some mice have a “wheel" which can be used for scrolling. Emacs supports scrolling windows with the mouse wheel, by default, on most graphical displays. To toggle this feature, use
M-x mouse-wheel-mode. The variables
mouse-wheel-scroll-amount determine where and by how much buffers are scrolled. The variable
mouse-wheel-progressive-speed determines whether the scroll speed is linked to how fast you move the wheel. This mode also supports increasing or decreasing the height of the default face, by default bound to scrolling with the
Emacs can also support horizontal scrolling if your mouse’s wheel can be tilted, or if your touchpad supports it. This feature is off by default; the variable
mouse-wheel-tilt-scroll turns it on, if you customize it to a non-
nil value. By default, tilting the mouse wheel scrolls the window’s view horizontally in the direction of the tilt: e.g., tilting to the right scrolls the window to the right, so that the text displayed in the window moves horizontally to the left. If you’d like to reverse the direction of horizontal scrolling, customize the variable
mouse-wheel-flip-direction to a non-
When the mouse pointer is over an image in Image mode, see Image Mode, scrolling the mouse wheel with the
Ctrl modifier scales the image under the mouse pointer.