blob: c6577906179e52e1fbca2d8d7cb454d0ffc80132 [file] [log] [blame]
Bram Moolenaar03413f42016-04-12 21:07:15 +02001*gui_x11.txt* For Vim version 7.4. Last change: 2016 Apr 08
Bram Moolenaar071d4272004-06-13 20:20:40 +00002
3
4 VIM REFERENCE MANUAL by Bram Moolenaar
5
6
7Vim's Graphical User Interface *gui-x11* *GUI-X11*
8 *Athena* *Motif*
91. Starting the X11 GUI |gui-x11-start|
102. GUI Resources |gui-resources|
113. Shell Commands |gui-pty|
124. Various |gui-x11-various|
135. GTK version |gui-gtk|
146. GNOME version |gui-gnome|
Bram Moolenaarc9b4b052006-04-30 18:54:39 +0000157. KDE version |gui-kde|
Bram Moolenaar843ee412004-06-30 16:16:41 +0000168. Compiling |gui-x11-compiling|
179. X11 selection mechanism |x11-selection|
Bram Moolenaar071d4272004-06-13 20:20:40 +000018
19Other relevant documentation:
20|gui.txt| For generic items of the GUI.
21
22{Vi does not have any of these commands}
23
24==============================================================================
251. Starting the X11 GUI *gui-x11-start* *E665*
26
27Then you can run the GUI version of Vim in either of these ways:
28 gvim [options] [files...]
29 vim -g [options] [files...]
30
31So if you call the executable "gvim", or make "gvim" a link to the executable,
32then the GUI version will automatically be used. Additional characters may be
33added after "gvim", for example "gvim-5".
34
35You may also start up the GUI from within the terminal version by using one of
36these commands:
37 :gui [++opt] [+cmd] [-f|-b] [files...] *:gu* *:gui*
38 :gvim [++opt] [+cmd] [-f|-b] [files...] *:gv* *:gvim*
39The "-f" option runs Vim in the foreground.
40The "-b" option runs Vim in the background (this is the default).
41Also see |++opt| and |+cmd|.
42
43 *gui-fork*
44When the GUI is started, it does a fork() and exits the current process.
45When gvim was started from a shell this makes the shell accept further
46commands. If you don't want this (e.g. when using gvim for a mail program
47that waits for gvim to exit), start gvim with "gvim -f", "vim -gf" or use
48":gui -f". Don't use "vim -fg", because "-fg" specifies the foreground
49color.
50
51When using "gvim -f" and then ":gui", Vim will run in the foreground. The
52"-f" argument will be remembered. To force running Vim in the background use
53":gui -b".
54
55"gvim --nofork" does the same as "gvim -f".
Bram Moolenaar5302d9e2011-09-14 17:55:08 +020056 *E851* *E852*
57When starting the GUI fails Vim will try to continue running in the terminal.
Bram Moolenaar071d4272004-06-13 20:20:40 +000058
59If you want the GUI to run in the foreground always, include the 'f'
60flag in 'guioptions'. |-f|.
61
62==============================================================================
632. GUI Resources *gui-resources* *.Xdefaults*
64
Bram Moolenaar843ee412004-06-30 16:16:41 +000065If using the Motif or Athena version of the GUI (not for the KDE, GTK+ or Win32
Bram Moolenaar071d4272004-06-13 20:20:40 +000066version), a number of X resources are available. You should use Vim's class
67"Vim" when setting these. They are as follows:
68
69 Resource name Meaning ~
70
71 reverseVideo Boolean: should reverse video be used?
72 background Color of background.
73 foreground Color of normal text.
74 scrollBackground Color of trough portion of scrollbars.
75 scrollForeground Color of slider and arrow portions of scrollbars.
76 menuBackground Color of menu backgrounds.
77 menuForeground Color of menu foregrounds.
78 tooltipForeground Color of tooltip and balloon foreground.
79 tooltipBackground Color of tooltip and balloon background.
80
81 font Name of font used for normal text.
82 boldFont Name of font used for bold text.
83 italicFont Name of font used for italic text.
84 boldItalicFont Name of font used for bold, italic text.
85 menuFont Name of font used for the menus, used when compiled
86 without the |+xfontset| feature
87 menuFontSet Name of fontset used for the menus, used when compiled
88 with the |+xfontset| feature
89 tooltipFont Name of the font used for the tooltip and balloons.
90 When compiled with the |+xfontset| feature this is a
91 fontset name.
92
93 geometry Initial geometry to use for gvim's window (default
94 is same size as terminal that started it).
95 scrollbarWidth Thickness of scrollbars.
96 borderWidth Thickness of border around text area.
97 menuHeight Height of the menu bar (only for Athena).
98
99A special font for italic, bold, and italic-bold text will only be used if
100the user has specified one via a resource. No attempt is made to guess what
101fonts should be used for these based on the normal text font.
102
103Note that the colors can also be set with the ":highlight" command, using the
104"Normal", "Menu", "Tooltip", and "Scrollbar" groups. Example: >
105 :highlight Menu guibg=lightblue
106 :highlight Tooltip guibg=yellow
107 :highlight Scrollbar guibg=lightblue guifg=blue
108 :highlight Normal guibg=grey90
109<
110 *font-sizes*
111Note: All fonts (except for the menu and tooltip) must be of the same size!!!
112If you don't do this, text will disappear or mess up the display. Vim does
113not check the font sizes. It's the size in screen pixels that must be the
114same. Note that some fonts that have the same point size don't have the same
115pixel size! Additionally, the positioning of the fonts must be the same
116(ascent and descent). You can check this with "xlsfonts -l {fontname}".
117
Bram Moolenaar402d2fe2005-04-15 21:00:38 +0000118If any of these things are also set with Vim commands, e.g. with
Bram Moolenaar071d4272004-06-13 20:20:40 +0000119":set guifont=Screen15", then this will override the X resources (currently
120'guifont' is the only option that is supported).
121
122Here is an example of what you might put in your ~/.Xdefaults file: >
123
124 Vim*useSchemes: all
125 Vim*sgiMode: true
126 Vim*useEnhancedFSB: true
127 Vim.foreground: Black
128 Vim.background: Wheat
129 Vim*fontList: 7x13
130
131The first three of these are standard resources on Silicon Graphics machines
132which make Motif applications look even better, highly recommended!
133
134The "Vim*fontList" is to set the menu font for Motif. Example: >
135 Vim*menuBar*fontList: -*-courier-medium-r-*-*-10-*-*-*-*-*-*-*
136With Athena: >
137 Vim*menuBar*SmeBSB*font: -*-courier-medium-r-*-*-10-*-*-*-*-*-*-*
138 Vim*menuBar*MenuButton*font: -*-courier-medium-r-*-*-10-*-*-*-*-*-*-*
139
140NOTE: A more portable, and indeed more correct, way to specify the menu font
141in either Motif or Athena is through the resource: >
142 Vim.menuFont: -*-courier-medium-r-*-*-10-*-*-*-*-*-*-*
143Or, when compiled with the |+xfontset| feature: >
144 Vim.menuFontSet: -*-courier-medium-r-*-*-10-*-*-*-*-*-*-*
145
146Don't use "Vim*geometry" in the defaults. This will break the menus. Use
147"Vim.geometry" instead.
148
149If you get an error message "Cannot allocate colormap entry for "gray60",
150try adding this to your Vim resources (change the colors to your liking): >
151
152 Vim*scrollBackground: Black
153 Vim*scrollForeground: Blue
154
155The resources can also be set with arguments to Vim:
156
157 argument meaning ~
158 *-gui*
159 -display {display} Run vim on {display} *-display*
160 -iconic Start vim iconified *-iconic*
161 -background {color} Use {color} for the background *-background*
162 -bg {color} idem *-bg*
163 -foreground {color} Use {color} for normal text *-foreground*
164 -fg {color} idem *-fg*
165 -ul {color} idem *-ul*
166 -font {font} Use {font} for normal text *-font*
167 -fn {font} idem *-fn*
168 -boldfont {font} Use {font} for bold text *-boldfont*
169 -italicfont {font} Use {font} for italic text *-italicfont*
170 -menufont {font} Use {font} for menu items *-menufont*
171 -menufontset {fontset} Use {fontset} for menu items *-menufontset*
172 -mf {font} idem *-mf*
173 -geometry {geom} Use {geom} for initial geometry *-geometry*
174 -geom {geom} idem, see |-geometry-example| *-geom*
175 -borderwidth {width} Use a border width of {width} *-borderwidth*
176 -bw {width} idem *-bw*
177 *-scrollbarwidth*
178 -scrollbarwidth {width} Use a scrollbar width of {width}
179 -sw {width} idem *-sw*
180 -menuheight {height} Use a menu bar height of {height} *-menuheight*
181 -mh {height} idem *-mh*
182 NOTE: On Motif the value is ignored, the menu height
183 is computed to fit the menus.
184 -reverse Use reverse video *-reverse*
185 -rv idem *-rv*
186 +reverse Don't use reverse video *-+reverse*
187 +rv idem *-+rv*
188 -xrm {resource} Set the specified resource *-xrm*
189
190Note about reverse video: Vim checks that the result is actually a light text
191on a dark background. The reason is that some X11 versions swap the colors,
192and some don't. These two examples will both give yellow text on a blue
193background:
194 gvim -fg Yellow -bg Blue -reverse
195 gvim -bg Yellow -fg Blue -reverse
196
197 *-geometry-example*
198An example for the geometry argument: >
199 gvim -geometry 80x63+8+100
200This creates a window with 80 columns and 63 lines at position 8 pixels from
201the left and 100 pixels from the top of the screen.
202
203==============================================================================
2043. Shell Commands *gui-pty*
205
206WARNING: Executing an external command from the GUI will not always work.
207"normal" commands like "ls", "grep" and "make" mostly work fine. Commands
208that require an intelligent terminal like "less" and "ispell" won't work.
209Some may even hang and need to be killed from another terminal. So be
210careful!
211
212There are two ways to do the I/O with a shell command: Pipes and a pseudo-tty.
213The default is to use a pseudo-tty. This should work best on most systems.
214
215Unfortunately, the implementation of the pseudo-tty is different on every Unix
216system. And some systems require root permission. To avoid running into
217problems with a pseudo-tty when you least expect it, test it when not editing
218a file. Be prepared to "kill" the started command or Vim. Commands like
219":r !cat" may hang!
220
221If using a pseudo-tty does not work for you, reset the 'guipty' option: >
222
223 :set noguipty
224
225Using a pipe should work on any Unix system, but there are disadvantages:
226- Some shell commands will notice that a pipe is being used and behave
227 differently. E.g., ":!ls" will list the files in one column.
228- The ":sh" command won't show a prompt, although it will sort of work.
229- When using ":make" it's not possible to interrupt with a CTRL-C.
230
231Typeahead while the external command is running is often lost. This happens
232both with a pipe and a pseudo-tty. This is a known problem, but it seems it
233can't be fixed (or at least, it's very difficult).
234
235 *gui-pty-erase*
236When your erase character is wrong for an external command, you should fix
237this in your "~/.cshrc" file, or whatever file your shell uses for
238initializations. For example, when you want to use backspace to delete
239characters, but hitting backspaces produces "^H" instead, try adding this to
240your "~/.cshrc": >
241 stty erase ^H
242The ^H is a real CTRL-H, type it as CTRL-V CTRL-H.
243
244==============================================================================
2454. Various *gui-x11-various*
246
247 *gui-x11-printing*
248The "File/Print" menu simply sends the current buffer to "lpr". No options or
249whatever. If you want something else, you can define your own print command.
250For example: >
251
252 :10amenu File.Print :w !lpr -Php3
253 :10vmenu File.Print :w !lpr -Php3
254<
255 *X11-icon*
256Vim uses a black&white icon by default when compiled with Motif or Athena. A
257colored Vim icon is included as $VIMRUNTIME/vim32x32.xpm. For GTK+, this is
258the builtin icon used. Unfortunately, how you should install it depends on
259your window manager. When you use this, remove the 'i' flag from
260'guioptions', to remove the black&white icon: >
261 :set guioptions-=i
262
263If you use one of the fvwm* family of window managers simply add this line to
264your .fvwm2rc configuration file: >
265
266 Style "vim" Icon vim32x32.xpm
267
268Make sure the icon file's location is consistent with the window manager's
269ImagePath statement. Either modify the ImagePath from within your .fvwm2rc or
270drop the icon into one the pre-defined directories: >
271
272 ImagePath /usr/X11R6/include/X11/pixmaps:/usr/X11R6/include/X11/bitmaps
273
274Note: older versions of fvwm use "IconPath" instead of "ImagePath".
275
276For CDE "dtwm" (a derivative of Motif) add this line in the .Xdefaults: >
277 Dtwm*Vim*iconImage: /usr/local/share/vim/vim32x32.xpm
278
279For "mwm" (Motif window manager) the line would be: >
280 Mwm*Vim*iconImage: /usr/local/share/vim/vim32x32.xpm
281
282Mouse Pointers Available in X11 *X11_mouse_shapes*
283
284By using the |'mouseshape'| option, the mouse pointer can be automatically
285changed whenever Vim enters one of its various modes (e.g., Insert or
286Command). Currently, the available pointers are:
287
288 arrow an arrow pointing northwest
289 beam a I-like vertical bar
290 size an arrow pointing up and down
291 busy a wristwatch
292 blank an invisible pointer
293 crosshair a thin "+" sign
294 hand1 a dark hand pointing northeast
295 hand2 a light hand pointing northwest
296 pencil a pencil pointing southeast
297 question question_arrow
298 right_arrow an arrow pointing northeast
299 up_arrow an arrow pointing upwards
300
301Additionally, any of the mouse pointers that are built into X11 may be
302used by specifying an integer from the X11/cursorfont.h include file.
303
304If a name is used that exists on other systems, but not in X11, the default
305"arrow" pointer is used.
306
307==============================================================================
Bram Moolenaar03413f42016-04-12 21:07:15 +02003085. GTK version *gui-gtk* *GTK+* *GTK* *GTK3*
Bram Moolenaar071d4272004-06-13 20:20:40 +0000309
310The GTK version of the GUI works a little bit different.
311
312GTK does _not_ use the traditional X resource settings. Thus items in your
313~/.Xdefaults or app-defaults files are not used.
314Many of the traditional X command line arguments are not supported. (e.g.,
315stuff like -bg, -fg, etc). The ones that are supported are:
316
317 command line argument resource name meaning ~
318 -fn or -font .font font name for the text
319 -geom or -geometry .geometry size of the gvim window
320 -rv or -reverse *reverseVideo white text on black background
321 -display display to be used
322 -fg -foreground {color} foreground color
323 -bg -background {color} background color
324
325To set the font, see |'guifont'|. For GTK, there's also a menu option that
326does this.
327
328Additionally, there are these command line arguments, which are handled by GTK
329internally. Look in the GTK documentation for how they are used:
330 --sync
331 --gdk-debug
332 --gdk-no-debug
333 --no-xshm (not in GTK+ 2)
334 --xim-preedit (not in GTK+ 2)
335 --xim-status (not in GTK+ 2)
336 --gtk-debug
337 --gtk-no-debug
338 --g-fatal-warnings
339 --gtk-module
340 --display (GTK+ counterpart of -display; works the same way.)
341 --screen (The screen number; for GTK+ 2.2 multihead support.)
342
343These arguments are ignored when the |+netbeans_intg| feature is used:
344 -xrm
345 -mf
346
347As for colors, Vim's color settings (for syntax highlighting) is still
348done the traditional Vim way. See |:highlight| for more help.
349
350If you want to set the colors of remaining gui components (e.g., the
351menubar, scrollbar, whatever), those are GTK specific settings and you
352need to set those up in some sort of gtkrc file. You'll have to refer
353to the GTK documentation, however little there is, on how to do this.
354See http://developer.gnome.org/doc/API/2.0/gtk/gtk-Resource-Files.html
355for more information.
356
357 *gtk-tooltip-colors*
358Example, which sets the tooltip colors to black on light-yellow: >
359
360 style "tooltips"
361 {
362 bg[NORMAL] = "#ffffcc"
363 fg[NORMAL] = "#000000"
364 }
365
366 widget "gtk-tooltips*" style "tooltips"
367
368Write this in the file ~/.gtkrc and it will be used by GTK+. For GTK+ 2
369you might have to use the file ~/.gtkrc-2.0 instead, depending on your
370distribution.
371
Bram Moolenaar98921892016-02-23 17:14:37 +0100372For GTK+ 3, an effect similar to the above can be obtained by adding the
373following snippet of CSS code to $XDG_HOME_DIR/gtk-3.0/gtk.css (usually,
374$HOME/.config/gtk-3.0/gtk.css):
375 >
376 .tooltip {
377 background-color: #ffffcc;
378 color: #000000;
379 }
380<
381
Bram Moolenaar071d4272004-06-13 20:20:40 +0000382Using Vim as a GTK+ plugin *gui-gtk-socketid*
383
384When the GTK+ version of Vim starts up normally, it creates its own top level
385window (technically, a 'GtkWindow'). GTK+ provides an embedding facility with
386its GtkSocket and GtkPlug widgets. If one GTK+ application creates a
387GtkSocket widget in one of its windows, an entirely different GTK+ application
388may embed itself into the first application by creating a top-level GtkPlug
389widget using the socket's ID.
390
391If you pass Vim the command-line option '--socketid' with a decimal or
392hexadecimal value, Vim will create a GtkPlug widget using that value instead
393of the normal GtkWindow. This enables Vim to act as a GTK+ plugin.
394
395This really is a programmer's interface, and is of no use without a supporting
396application to spawn the Vim correctly. For more details on GTK+ sockets, see
397http://www.gtk.org/api/
398
399Note that this feature requires the latest GTK version. GTK 1.2.10 still has
400a small problem. The socket feature has not yet been tested with GTK+ 2 --
401feel free to volunteer.
402
403==============================================================================
4046. GNOME version *gui-gnome* *Gnome* *GNOME*
405
406The GNOME GUI works just like the GTK+ version. See |GTK+| above for how it
407works. It looks a bit different though, and implements one important feature
408that's not available in the plain GTK+ GUI: Interaction with the session
409manager. |gui-gnome-session|
410
411These are the different looks:
412- Uses GNOME dialogs (GNOME 1 only). The GNOME 2 GUI uses the same nice
413 dialogs as the GTK+ 2 version.
414- Uses the GNOME dock, so that the toolbar and menubar can be moved to
415 different locations other than the top (e.g., the toolbar can be placed on
416 the left, right, top, or bottom). The placement of the menubar and
417 toolbar is only saved in the GNOME 2 version.
418- That means the menubar and toolbar handles are back! Yeah! And the
419 resizing grid still works too.
420
Bram Moolenaar9964e462007-05-05 17:54:07 +0000421GNOME is compiled with if it was found by configure and the
422--enable-gnome-check argument was used.
423
Bram Moolenaar071d4272004-06-13 20:20:40 +0000424
425GNOME session support *gui-gnome-session* *gnome-session*
426
427On logout, Vim shows the well-known exit confirmation dialog if any buffers
428are modified. Clicking [Cancel] will stop the logout process. Otherwise the
429current session is stored to disk by using the |:mksession| command, and
430restored the next time you log in.
431
432The GNOME session support should also work with the KDE session manager.
433If you are experiencing any problems please report them as bugs.
434
435Note: The automatic session save works entirely transparent, in order to
436avoid conflicts with your own session files, scripts and autocommands. That
437means in detail:
438- The session file is stored to a separate directory (usually $HOME/.gnome2).
439- 'sessionoptions' is ignored, and a hardcoded set of appropriate flags is
440 used instead: >
Bram Moolenaar446cb832008-06-24 21:56:24 +0000441 blank,curdir,folds,globals,help,options,tabpages,winsize
Bram Moolenaar071d4272004-06-13 20:20:40 +0000442- The internal variable |v:this_session| is not changed when storing the
443 session. Also, it is restored to its old value when logging in again.
444
445The position and size of the GUI window is not saved by Vim since doing so
446is the window manager's job. But if compiled with GTK+ 2 support, Vim helps
447the WM to identify the window by restoring the window role (using the |--role|
448command line argument).
449
450==============================================================================
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +00004517. KDE version *gui-kde* *kde* *KDE* *KVim*
Bram Moolenaar9964e462007-05-05 17:54:07 +0000452 *gui-x11-kde*
Bram Moolenaar9372a112005-12-06 19:59:18 +0000453There is no KDE version of Vim. There has been some work on a port using the
454Qt toolkit, but it never worked properly and it has been abandoned. Work
Bram Moolenaar08589172014-03-08 18:38:28 +0100455continues on Yzis: https://github.com/chrizel/Yzis.
Bram Moolenaar843ee412004-06-30 16:16:41 +0000456
457==============================================================================
4588. Compiling *gui-x11-compiling*
Bram Moolenaar071d4272004-06-13 20:20:40 +0000459
460If using X11, Vim's Makefile will by default first try to find the necessary
461GTK+ files on your system. If the GTK+ files cannot be found, then the Motif
462files will be searched for. Finally, if this fails, the Athena files will be
463searched for. If all three fail, the GUI will be disabled.
464
465For GTK+, Vim's configuration process requires that GTK+ be properly
466installed. That is, the shell script 'gtk-config' must be in your PATH, and
467you can already successful compile, build, and execute a GTK+ program. The
Bram Moolenaar06b5d512010-05-22 15:37:44 +0200468reason for this is that the compiler flags (CFLAGS) and link flags (LDFLAGS)
469are obtained through the 'gtk-config' shell script.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000470
471If you want to build with GTK+ 2 support pass the --enable-gtk2-check argument
472to ./configure. Optionally, support for GNOME 2 will be compiled if the
Bram Moolenaar97ea5112010-06-12 06:46:44 +0200473--enable-gnome-check option is also given.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000474
475Otherwise, if you are using Motif or Athena, when you have the Motif or Athena
476files in a directory where configure doesn't look, edit the Makefile to enter
477the names of the directories. Search for "GUI_INC_LOC" for an example to set
478the Motif directories, "CONF_OPT_X" for Athena.
479
480 *gui-x11-gtk*
Bram Moolenaar97ea5112010-06-12 06:46:44 +0200481At the time of this writing, GTK+ version 1.0.6 and 1.2 are outdated. It
482is suggested that you use GTK 2. The GTK 1 support will most likely be
483dropped soon.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000484
Bram Moolenaar97ea5112010-06-12 06:46:44 +0200485For the GTK+ 2 GUI, using the latest release of the GTK+ 2.0 or GTK+ 2.2
486series is recommended.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000487
488Lastly, although GTK+ has supposedly been ported to the Win32 platform, this
489has not been tested with Vim and is also unsupported. Also, it's unlikely to
490even compile since GTK+ GUI uses parts of the generic X11 code. This might
491change in distant future; particularly because getting rid of the X11 centric
492code parts is also required for GTK+ framebuffer support.
493
494 *gui-x11-motif*
495For Motif, you need at least Motif version 1.2 and/or X11R5. Motif 2.0 and
496X11R6 are OK. Motif 1.1 and X11R4 might work, no guarantee (there may be a
497few problems, but you might make it compile and run with a bit of work, please
498send me the patches if you do). The newest releases of LessTif have been
499reported to work fine too.
500
501 *gui-x11-athena*
502The Athena version uses the Xaw widget set by default. If you have the 3D
503version, you might want to link with Xaw3d instead. This will make the
504menus look a bit better. Edit the Makefile and look for "XAW_LIB". The
505scrollbars will remain the same, because Vim has its own, which are already
5063D (in fact, they look more like Motif).
507
508 *gui-x11-neXtaw*
509The neXtaw version is mostly like Athena, but uses different widgets.
510
511 *gui-x11-misc*
512In general, do not try to mix files from different GTK+, Motif, Athena and X11
513versions. This will cause problems. For example, using header files for
514X11R5 with a library for X11R6 probably doesn't work (although the linking
515won't give an error message, Vim will crash later).
516
517==============================================================================
Bram Moolenaar843ee412004-06-30 16:16:41 +00005189. X11 selection mechanism *x11-selection*
Bram Moolenaar071d4272004-06-13 20:20:40 +0000519
520If using X11, in either the GUI or an xterm with an X11-aware Vim, then Vim
521provides varied access to the X11 selection and clipboard. These are accessed
522by using the two selection registers "* and "+.
523
524X11 provides two basic types of global store, selections and cut-buffers,
525which differ in one important aspect: selections are "owned" by an
526application, and disappear when that application (e.g., Vim) exits, thus
527losing the data, whereas cut-buffers, are stored within the X-server itself
528and remain until written over or the X-server exits (e.g., upon logging out).
529
530The contents of selections are held by the originating application (e.g., upon
531a copy), and only passed on to another application when that other application
532asks for them (e.g., upon a paste).
533
534The contents of cut-buffers are immediately written to, and are then
535accessible directly from the X-server, without contacting the originating
536application.
537
538 *quoteplus* *quote+*
539There are three documented X selections: PRIMARY (which is expected to
540represent the current visual selection - as in Vim's Visual mode), SECONDARY
541(which is ill-defined) and CLIPBOARD (which is expected to be used for
542cut, copy and paste operations).
543
544Of these three, Vim uses PRIMARY when reading and writing the "* register
545(hence when the X11 selections are available, Vim sets a default value for
546|'clipboard'| of "autoselect"), and CLIPBOARD when reading and writing the "+
547register. Vim does not access the SECONDARY selection.
548
549Examples: (assuming the default option values)
Bram Moolenaar8f3f58f2010-01-06 20:52:26 +0100550- Select an URL in Visual mode in Vim. Go to your browser and click the
551 middle mouse button in the URL text field. The selected text will be
552 inserted (hopefully!). Note: in Firefox you can set the
553 middlemouse.contentLoadURL preference to true in about:config, then the
554 selected URL will be used when pressing middle mouse button in most places
555 in the window.
556- Select some text in your browser by dragging with the mouse. Go to Vim and
Bram Moolenaar071d4272004-06-13 20:20:40 +0000557 press the middle mouse button: The selected text is inserted.
Bram Moolenaar8f3f58f2010-01-06 20:52:26 +0100558- Select some text in Vim and do "+y. Go to your browser, select some text in
559 a textfield by dragging with the mouse. Now use the right mouse button and
Bram Moolenaar071d4272004-06-13 20:20:40 +0000560 select "Paste" from the popup menu. The selected text is overwritten by the
561 text from Vim.
562Note that the text in the "+ register remains available when making a Visual
563selection, which makes other text available in the "* register. That allows
564overwriting selected text.
565 *x11-cut-buffer*
566There are, by default, 8 cut-buffers: CUT_BUFFER0 to CUT_BUFFER7. Vim only
567uses CUT_BUFFER0, which is the one that xterm uses by default.
568
569Whenever Vim is about to become unavailable (either via exiting or becoming
570suspended), and thus unable to respond to another application's selection
571request, it writes the contents of any owned selection to CUT_BUFFER0. If the
572"+ CLIPBOARD selection is owned by Vim, then this is written in preference,
573otherwise if the "* PRIMARY selection is owned by Vim, then that is written.
574
575Similarly, when Vim tries to paste from "* or "+ (either explicitly, or, in
576the case of the "* register, when the middle mouse button is clicked), if the
577requested X selection is empty or unavailable, Vim reverts to reading the
578current value of the CUT_BUFFER0.
579
580Note that when text is copied to CUT_BUFFER0 in this way, the type of
581selection (character, line or block) is always lost, even if it is a Vim which
582later pastes it.
583
584Xterm, by default, always writes visible selections to both PRIMARY and
585CUT_BUFFER0. When it pastes, it uses PRIMARY if this is available, or else
586falls back upon CUT_BUFFER0. For this reason, when cutting and pasting
587between Vim and an xterm, you should use the "* register. Xterm doesn't use
588CLIPBOARD, thus the "+ doesn't work with xterm.
589
590Most newer applications will provide their current selection via PRIMARY ("*)
591and use CLIPBOARD ("+) for cut/copy/paste operations. You thus have access to
592both by choosing to use either of the "* or "+ registers.
593
594
595 vim:tw=78:sw=4:ts=8:ft=help:norl: