How to auto copy when a region is selected?

[Originally posted by]: http://emacs.stackexchange.com/questions/17170/how-to-auto-copy-when-a-region-is-selected

The selection can be copied automatically if the OS supports primary selection by setting the below variable.

(setq x-select-enable-primary t)

From C-h v x-select-enable-primary, you get,

Non-nil means cutting and pasting uses the primary selection The existence of a primary selection depends on the underlying GUI you use. E.g. it doesn’t exist under MS-Windows.

To learn even more, visit the relevant info node by doing C-h i g (emacs) Primary Selection.


Another variable setting that goes in tandem with the above is to set the x-select-enable-clipboardto t. Doing that allows you to yank the contents copied from other X11 applications into emacs.

(setq x-select-enable-clipboard t)

When emacs 25.1 is released (supposedly the next stable version after 24.5), the x-select-enable-primary variable name will be deprecated and select-enable-primary must be used instead (removal of that x- prefix). Similarly x-select-enable-clipboard will be deprecated in favor of select-enable-clipboard.

shareimprove this answer
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s