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