1*gui_x11.txt* For Vim version 8.2. Last change: 2020 Jun 05 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 23============================================================================== 241. Starting the X11 GUI *gui-x11-start* *E665* 25 26Then you can run the GUI version of Vim in either of these ways: 27 gvim [options] [files...] 28 vim -g [options] [files...] 29 30So if you call the executable "gvim", or make "gvim" a link to the executable, 31then the GUI version will automatically be used. Additional characters may be 32added after "gvim", for example "gvim-5". 33 34You may also start up the GUI from within the terminal version by using one of 35these commands: 36 :gui [++opt] [+cmd] [-f|-b] [files...] *:gu* *:gui* 37 :gvim [++opt] [+cmd] [-f|-b] [files...] *:gv* *:gvim* 38The "-f" option runs Vim in the foreground. 39The "-b" option runs Vim in the background (this is the default). 40Also see |++opt| and |+cmd|. 41 42 *gui-fork* 43When the GUI is started, it does a fork() and exits the current process. 44When gvim was started from a shell this makes the shell accept further 45commands. If you don't want this (e.g. when using gvim for a mail program 46that waits for gvim to exit), start gvim with "gvim -f", "vim -gf" or use 47":gui -f". Don't use "vim -fg", because "-fg" specifies the foreground 48color. 49 50When using "vim -f" and then ":gui", Vim will run in the foreground. The 51"-f" argument will be remembered. To force running Vim in the background use 52":gui -b". 53 54"gvim --nofork" does the same as "gvim -f". 55 56When there are running jobs Vim will not fork, because the processes would no 57longer be child processes. 58 *E851* *E852* 59When starting the GUI fails Vim will try to continue running in the terminal. 60 61If you want the GUI to run in the foreground always, include the 'f' 62flag in 'guioptions'. |-f|. 63 64============================================================================== 652. GUI Resources *gui-resources* *.Xdefaults* 66 67If using the Motif or Athena version of the GUI (not for the KDE, GTK+ or Win32 68version), a number of X resources are available. You should use Vim's class 69"Vim" when setting these. They are as follows: 70 71 Resource name Meaning ~ 72 73 reverseVideo Boolean: should reverse video be used? 74 background Color of background. 75 foreground Color of normal text. 76 scrollBackground Color of trough portion of scrollbars. 77 scrollForeground Color of slider and arrow portions of scrollbars. 78 menuBackground Color of menu backgrounds. 79 menuForeground Color of menu foregrounds. 80 tooltipForeground Color of tooltip and balloon foreground. 81 tooltipBackground Color of tooltip and balloon background. 82 83 font Name of font used for normal text. 84 boldFont Name of font used for bold text. 85 italicFont Name of font used for italic text. 86 boldItalicFont Name of font used for bold, italic text. 87 menuFont Name of font used for the menus, used when compiled 88 without the |+xfontset| feature 89 menuFontSet Name of fontset used for the menus, used when compiled 90 with the |+xfontset| feature 91 tooltipFont Name of the font used for the tooltip and balloons. 92 When compiled with the |+xfontset| feature this is a 93 fontset name. 94 95 geometry Initial geometry to use for gvim's window (default 96 is same size as terminal that started it). 97 scrollbarWidth Thickness of scrollbars. 98 borderWidth Thickness of border around text area. 99 menuHeight Height of the menu bar (only for Athena). 100 101A special font for italic, bold, and italic-bold text will only be used if 102the user has specified one via a resource. No attempt is made to guess what 103fonts should be used for these based on the normal text font. 104 105Note that the colors can also be set with the ":highlight" command, using the 106"Normal", "Menu", "Tooltip", and "Scrollbar" groups. Example: > 107 :highlight Menu guibg=lightblue 108 :highlight Tooltip guibg=yellow 109 :highlight Scrollbar guibg=lightblue guifg=blue 110 :highlight Normal guibg=grey90 111< 112 *font-sizes* 113Note: All fonts (except for the menu and tooltip) must be of the same size!!! 114If you don't do this, text will disappear or mess up the display. Vim does 115not check the font sizes. It's the size in screen pixels that must be the 116same. Note that some fonts that have the same point size don't have the same 117pixel size! Additionally, the positioning of the fonts must be the same 118(ascent and descent). You can check this with "xlsfonts -l {fontname}". 119 120If any of these things are also set with Vim commands, e.g. with 121":set guifont=Screen15", then this will override the X resources (currently 122'guifont' is the only option that is supported). 123 124Here is an example of what you might put in your ~/.Xdefaults file: > 125 126 Vim*useSchemes: all 127 Vim*sgiMode: true 128 Vim*useEnhancedFSB: true 129 Vim.foreground: Black 130 Vim.background: Wheat 131 Vim*fontList: 7x13 132 133The first three of these are standard resources on Silicon Graphics machines 134which make Motif applications look even better, highly recommended! 135 136The "Vim*fontList" is to set the menu font for Motif. Example: > 137 Vim*menuBar*fontList: -*-courier-medium-r-*-*-10-*-*-*-*-*-*-* 138With Athena: > 139 Vim*menuBar*SmeBSB*font: -*-courier-medium-r-*-*-10-*-*-*-*-*-*-* 140 Vim*menuBar*MenuButton*font: -*-courier-medium-r-*-*-10-*-*-*-*-*-*-* 141 142NOTE: A more portable, and indeed more correct, way to specify the menu font 143in either Motif or Athena is through the resource: > 144 Vim.menuFont: -*-courier-medium-r-*-*-10-*-*-*-*-*-*-* 145Or, when compiled with the |+xfontset| feature: > 146 Vim.menuFontSet: -*-courier-medium-r-*-*-10-*-*-*-*-*-*-* 147 148Don't use "Vim*geometry" in the defaults. This will break the menus. Use 149"Vim.geometry" instead. 150 151If you get an error message "Cannot allocate colormap entry for "gray60", 152try adding this to your Vim resources (change the colors to your liking): > 153 154 Vim*scrollBackground: Black 155 Vim*scrollForeground: Blue 156 157The resources can also be set with arguments to Vim: 158 159 argument meaning ~ 160 *-gui* 161 -display {display} Run vim on {display} *-display* 162 -iconic Start vim iconified *-iconic* 163 -background {color} Use {color} for the background *-background* 164 -bg {color} idem *-bg* 165 -foreground {color} Use {color} for normal text *-foreground* 166 -fg {color} idem *-fg* 167 -ul {color} idem *-ul* 168 -font {font} Use {font} for normal text *-font* 169 -fn {font} idem *-fn* 170 -boldfont {font} Use {font} for bold text *-boldfont* 171 -italicfont {font} Use {font} for italic text *-italicfont* 172 -menufont {font} Use {font} for menu items *-menufont* 173 -menufontset {fontset} Use {fontset} for menu items *-menufontset* 174 -mf {font} idem *-mf* 175 -geometry {geom} Use {geom} for initial geometry *-geometry* 176 -geom {geom} idem, see |-geometry-example| *-geom* 177 -borderwidth {width} Use a border width of {width} *-borderwidth* 178 -bw {width} idem *-bw* 179 *-scrollbarwidth* 180 -scrollbarwidth {width} Use a scrollbar width of {width} 181 -sw {width} idem *-sw* 182 -menuheight {height} Use a menu bar height of {height} *-menuheight* 183 -mh {height} idem *-mh* 184 NOTE: On Motif the value is ignored, the menu height 185 is computed to fit the menus. 186 -reverse Use reverse video *-reverse* 187 -rv idem *-rv* 188 +reverse Don't use reverse video *-+reverse* 189 +rv idem *-+rv* 190 -xrm {resource} Set the specified resource *-xrm* 191 192Note about reverse video: Vim checks that the result is actually a light text 193on a dark background. The reason is that some X11 versions swap the colors, 194and some don't. These two examples will both give yellow text on a blue 195background: 196 gvim -fg Yellow -bg Blue -reverse 197 gvim -bg Yellow -fg Blue -reverse 198 199 *-geometry-example* 200An example for the geometry argument: > 201 gvim -geometry 80x63+8+100 202This creates a window with 80 columns and 63 lines at position 8 pixels from 203the left and 100 pixels from the top of the screen. 204 205============================================================================== 2063. Shell Commands *gui-pty* 207 208WARNING: Executing an external command from the GUI will not always work. 209"normal" commands like "ls", "grep" and "make" mostly work fine. Commands 210that require an intelligent terminal like "less" and "ispell" won't work. 211Some may even hang and need to be killed from another terminal. So be 212careful! 213 214There are two ways to do the I/O with a shell command: Pipes and a pseudo-tty. 215The default is to use a pseudo-tty. This should work best on most systems. 216 217Unfortunately, the implementation of the pseudo-tty is different on every Unix 218system. And some systems require root permission. To avoid running into 219problems with a pseudo-tty when you least expect it, test it when not editing 220a file. Be prepared to "kill" the started command or Vim. Commands like 221":r !cat" may hang! 222 223If using a pseudo-tty does not work for you, reset the 'guipty' option: > 224 225 :set noguipty 226 227Using a pipe should work on any Unix system, but there are disadvantages: 228- Some shell commands will notice that a pipe is being used and behave 229 differently. E.g., ":!ls" will list the files in one column. 230- The ":sh" command won't show a prompt, although it will sort of work. 231- When using ":make" it's not possible to interrupt with a CTRL-C. 232 233Typeahead while the external command is running is often lost. This happens 234both with a pipe and a pseudo-tty. This is a known problem, but it seems it 235can't be fixed (or at least, it's very difficult). 236 237 *gui-pty-erase* 238When your erase character is wrong for an external command, you should fix 239this in your "~/.cshrc" file, or whatever file your shell uses for 240initializations. For example, when you want to use backspace to delete 241characters, but hitting backspaces produces "^H" instead, try adding this to 242your "~/.cshrc": > 243 stty erase ^H 244The ^H is a real CTRL-H, type it as CTRL-V CTRL-H. 245 246============================================================================== 2474. Various *gui-x11-various* 248 249 *gui-x11-printing* 250The "File/Print" menu simply sends the current buffer to "lpr". No options or 251whatever. If you want something else, you can define your own print command. 252For example: > 253 254 :10amenu File.Print :w !lpr -Php3 255 :10vmenu File.Print :w !lpr -Php3 256< 257 *X11-icon* 258Vim uses a black&white icon by default when compiled with Motif or Athena. A 259colored Vim icon is included as $VIMRUNTIME/vim32x32.xpm. For GTK+, this is 260the builtin icon used. Unfortunately, how you should install it depends on 261your window manager. When you use this, remove the 'i' flag from 262'guioptions', to remove the black&white icon: > 263 :set guioptions-=i 264 265If you use one of the fvwm* family of window managers simply add this line to 266your .fvwm2rc configuration file: > 267 268 Style "vim" Icon vim32x32.xpm 269 270Make sure the icon file's location is consistent with the window manager's 271ImagePath statement. Either modify the ImagePath from within your .fvwm2rc or 272drop the icon into one the pre-defined directories: > 273 274 ImagePath /usr/X11R6/include/X11/pixmaps:/usr/X11R6/include/X11/bitmaps 275 276Note: older versions of fvwm use "IconPath" instead of "ImagePath". 277 278For CDE "dtwm" (a derivative of Motif) add this line in the .Xdefaults: > 279 Dtwm*Vim*iconImage: /usr/local/share/vim/vim32x32.xpm 280 281For "mwm" (Motif window manager) the line would be: > 282 Mwm*Vim*iconImage: /usr/local/share/vim/vim32x32.xpm 283 284 285Mouse Pointers Available in X11 ~ 286 *X11_mouse_shapes* 287By using the |'mouseshape'| option, the mouse pointer can be automatically 288changed whenever Vim enters one of its various modes (e.g., Insert or 289Command). Currently, the available pointers are: 290 291 arrow an arrow pointing northwest 292 beam a I-like vertical bar 293 size an arrow pointing up and down 294 busy a wristwatch 295 blank an invisible pointer 296 crosshair a thin "+" sign 297 hand1 a dark hand pointing northeast 298 hand2 a light hand pointing northwest 299 pencil a pencil pointing southeast 300 question question_arrow 301 right_arrow an arrow pointing northeast 302 up_arrow an arrow pointing upwards 303 304Additionally, any of the mouse pointers that are built into X11 may be 305used by specifying an integer from the X11/cursorfont.h include file. 306 307If a name is used that exists on other systems, but not in X11, the default 308"arrow" pointer is used. 309 310============================================================================== 3115. GTK version *gui-gtk* *GTK+* *GTK* *GTK3* 312 313The GTK version of the GUI works a little bit different. 314 315GTK does _not_ use the traditional X resource settings. Thus items in your 316~/.Xdefaults or app-defaults files are not used. 317Many of the traditional X command line arguments are not supported. (e.g., 318stuff like -bg, -fg, etc). The ones that are supported are: 319 320 command line argument resource name meaning ~ 321 -fn or -font .font font name for the text 322 -geom or -geometry .geometry size of the gvim window 323 -rv or -reverse *reverseVideo white text on black background 324 -display display to be used 325 -fg -foreground {color} foreground color 326 -bg -background {color} background color 327 328To set the font, see |'guifont'|. For GTK, there's also a menu option that 329does this. 330 331Additionally, there are these command line arguments, which are handled by GTK 332internally. Look in the GTK documentation for how they are used: 333 --sync 334 --gdk-debug 335 --gdk-no-debug 336 --no-xshm (not in GTK+ 2) 337 --xim-preedit (not in GTK+ 2) 338 --xim-status (not in GTK+ 2) 339 --gtk-debug 340 --gtk-no-debug 341 --g-fatal-warnings 342 --gtk-module 343 --display (GTK+ counterpart of -display; works the same way.) 344 --screen (The screen number; for GTK+ 2.2 multihead support.) 345 346These arguments are ignored when the |+netbeans_intg| feature is used: 347 -xrm 348 -mf 349 350As for colors, Vim's color settings (for syntax highlighting) is still 351done the traditional Vim way. See |:highlight| for more help. 352 353If you want to set the colors of remaining gui components (e.g., the 354menubar, scrollbar, whatever), those are GTK specific settings and you 355need to set those up in some sort of gtkrc file. You'll have to refer 356to the GTK documentation, however little there is, on how to do this. 357See http://developer.gnome.org/doc/API/2.0/gtk/gtk-Resource-Files.html 358for more information. 359 *gtk3-slow* 360If you are using GTK3 and Vim appears to be slow, try setting the environment 361variable $GDK_RENDERING to "image". 362 363 364Tooltip Colors ~ 365 *gtk-tooltip-colors* 366Example, which sets the tooltip colors to black on light-yellow: > 367 368 style "tooltips" 369 { 370 bg[NORMAL] = "#ffffcc" 371 fg[NORMAL] = "#000000" 372 } 373 374 widget "gtk-tooltips*" style "tooltips" 375 376Write this in the file ~/.gtkrc and it will be used by GTK+. For GTK+ 2 377you might have to use the file ~/.gtkrc-2.0 instead, depending on your 378distribution. 379 380For GTK+ 3, an effect similar to the above can be obtained by adding the 381following snippet of CSS code to $XDG_HOME_DIR/gtk-3.0/gtk.css (see the next 382section): 383 384For GTK+ 3 < 3.20: > 385 386 .tooltip { 387 background-color: #ffffcc; 388 color: #000000; 389 } 390< 391For GTK+ 3 >= 3.20: > 392 393 tooltip { 394 background-color: #ffffcc; 395 text-shadow: none; 396 } 397 398 tooltip label { 399 color: #2e3436; 400 } 401< 402 403A Quick Look at GTK+ CSS ~ 404 *gtk-css* 405The contents of this subsection apply to GTK+ 3.20 or later which provides 406stable support for GTK+ CSS: 407 408 https://developer.gnome.org/gtk3/stable/theming.html 409 410GTK+ uses CSS for styling and layout of widgets. In this subsection, we'll 411have a quick look at GTK+ CSS through simple, illustrative examples. 412 413You can usually edit the config with: > 414 vim $HOME/.config/gtk-3.0/gtk.css 415 416 417Example 1. Empty Space Adjustment ~ 418 419By default, the toolbar and the tabline of the GTK+ 3 GUI are somewhat larger 420than those of the GTK+ 2 GUI. Some people may want to make them look similar 421to the GTK+ 2 GUI in size. 422 423To do that, we'll try reducing empty space around icons and labels that looks 424apparently superfluous. 425 426Add the following lines to $XDG_HOME_DIR/gtk-3.0/gtk.css (usually, 427$HOME/.config/gtk-3.0/gtk.css): > 428 429 toolbar button { 430 margin-top: -2px; 431 margin-right: 0px; 432 margin-bottom: -2px; 433 margin-left: 0px; 434 435 padding-top: 0px; 436 padding-right: 0px; 437 padding-bottom: 0px; 438 padding-left: 0px 439 } 440 441 notebook tab { 442 margin-top: -1px; 443 margin-right: 3px; 444 margin-bottom: -1px; 445 margin-left: 3px; 446 447 padding-top: 0px; 448 padding-right: 0px; 449 padding-bottom: 0px; 450 padding-left: 0px 451 } 452< 453Since it's a CSS, they can be rewritten using shorthand: > 454 455 toolbar button { 456 margin: -2px 0px; 457 padding: 0px; 458 } 459 460 notebook tab { 461 margin: -1px 3px; 462 padding: 0px 463 } 464< 465Note: You might want to use 'toolbariconsize' to adjust the icon size, too. 466 467Note: Depending on the icon theme and/or the font in use, some extra tweaks 468may be needed for a satisfactory result. 469 470Note: In addition to margin and padding, you can use border. For details, 471refer to the box model of CSS, e.g., 472 473 https://www.w3schools.com/css/css_boxmodel.asp 474 475Example 2. More Than Just Colors ~ 476 477GTK+ CSS supports gradients as well: > 478 479 tooltip { 480 background-image: -gtk-gradient(linear, 481 0 0, 0 1, 482 color-stop(0, #344752), 483 color-stop(0.5, #546772), 484 color-stop(1, #243742)); 485 } 486 487 tooltip label { 488 color: #f3f3f3; 489 } 490< 491Gradients can be used to make a GUI element visually distinguishable from 492others without relying on high contrast. Accordingly, effective use of them is 493a useful technique to give a theme a sense of unity in color and luminance. 494 495Note: Theming can be difficult since it must make every application look 496equally good; making a single application more charming often gets others 497unexpectedly less attractive or even deteriorates their usability. Keep this 498in mind always when you try improving a theme. 499 500 501Example 3. border color ~ 502 503To eliminate borders when maximized: > 504 505 @define-color bg_color #1B2B34; 506 #vim-main-window { 507 background-color: @bg_color; 508 } 509 510 511Using Vim as a GTK+ plugin ~ 512 *gui-gtk-socketid* 513When the GTK+ version of Vim starts up normally, it creates its own top level 514window (technically, a 'GtkWindow'). GTK+ provides an embedding facility with 515its GtkSocket and GtkPlug widgets. If one GTK+ application creates a 516GtkSocket widget in one of its windows, an entirely different GTK+ application 517may embed itself into the first application by creating a top-level GtkPlug 518widget using the socket's ID. 519 520If you pass Vim the command-line option '--socketid' with a decimal or 521hexadecimal value, Vim will create a GtkPlug widget using that value instead 522of the normal GtkWindow. This enables Vim to act as a GTK+ plugin. 523 524This really is a programmer's interface, and is of no use without a supporting 525application to spawn the Vim correctly. For more details on GTK+ sockets, see 526http://www.gtk.org/api/ 527 528Note that this feature requires the latest GTK version. GTK 1.2.10 still has 529a small problem. The socket feature has not yet been tested with GTK+ 2 -- 530feel free to volunteer. 531 532============================================================================== 5336. GNOME version *gui-gnome* *Gnome* *GNOME* 534 535The GNOME GUI works just like the GTK+ version. See |GTK+| above for how it 536works. It looks a bit different though, and implements one important feature 537that's not available in the plain GTK+ GUI: Interaction with the session 538manager. |gui-gnome-session| 539 540These are the different looks: 541- Uses GNOME dialogs (GNOME 1 only). The GNOME 2 GUI uses the same nice 542 dialogs as the GTK+ 2 version. 543- Uses the GNOME dock, so that the toolbar and menubar can be moved to 544 different locations other than the top (e.g., the toolbar can be placed on 545 the left, right, top, or bottom). The placement of the menubar and 546 toolbar is only saved in the GNOME 2 version. 547- That means the menubar and toolbar handles are back! Yeah! And the 548 resizing grid still works too. 549 550GNOME is compiled with if it was found by configure and the 551--enable-gnome-check argument was used. 552 553Note: Avoid use of --enable-gnome-check with GTK+ 3 GUI build. The 554functionality mentioned above is consolidated in GTK+ 3. 555 556 557GNOME session support ~ 558 *gui-gnome-session* *gnome-session* 559On logout, Vim shows the well-known exit confirmation dialog if any buffers 560are modified. Clicking [Cancel] will stop the logout process. Otherwise the 561current session is stored to disk by using the |:mksession| command, and 562restored the next time you log in. 563 564The GNOME session support should also work with the KDE session manager. 565If you are experiencing any problems please report them as bugs. 566 567Note: The automatic session save works entirely transparent, in order to 568avoid conflicts with your own session files, scripts and autocommands. That 569means in detail: 570- The session file is stored to a separate directory (usually $HOME/.gnome2). 571- 'sessionoptions' is ignored, and a hardcoded set of appropriate flags is 572 used instead: > 573 blank,curdir,folds,globals,help,options,tabpages,winsize 574- The internal variable |v:this_session| is not changed when storing the 575 session. Also, it is restored to its old value when logging in again. 576 577The position and size of the GUI window is not saved by Vim since doing so 578is the window manager's job. But if compiled with GTK+ 2 support, Vim helps 579the WM to identify the window by restoring the window role (using the |--role| 580command line argument). 581 582============================================================================== 5837. KDE version *gui-kde* *kde* *KDE* *KVim* 584 *gui-x11-kde* 585There is no KDE version of Vim. There has been some work on a port using the 586Qt toolkit, but it never worked properly and it has been abandoned. Work 587continues on Yzis: https://github.com/chrizel/Yzis. 588 589============================================================================== 5908. Compiling *gui-x11-compiling* 591 592If using X11, Vim's configure will by default first try to find the necessary 593GTK+ files on your system. When both GTK+ 2 and GTK+ 3 are available, GTK+ 2 594will be chosen unless --enable-gui=gtk3 is passed explicitly to configure. 595 596If the GTK+ files cannot be found, then the Motif files will be searched for. 597Finally, if this fails, the Athena files will be searched for. If all three 598fail, the GUI will be disabled. 599 600For GTK+, Vim's configuration process uses pkg-config(1) to check if the 601GTK+ required for a specified build is properly installed and usable. 602Accordingly, it is a good idea to make sure before running configure that 603your system has a working pkg-config together with the .pc file of the 604required GTK+. For that, say, run the following on the command line to see if 605your pkg-config works with your GTK+ 2: > 606 607 $ pkg-config --modversion gtk+-2.0 608 609Replace gtk+-2.0 with gtk+-3.0 for GTK+ 3. If you get the correct version 610number of your GTK+, you can proceed; if not, you probably need to do some 611system administration chores to set up pkg-config and GTK+ correctly. 612 613The GTK+ 2 GUI is built by default. Therefore, you usually don't need to pass 614any options such as --enable-gui=gtk2 to configure and build that. 615 616Optionally, the GTK+ 2 GUI can consolidate the GNOME 2 support. This support 617is enabled by passing --enable-gnome-check to configure. 618 619If you want to build the GTK+ 3 GUI, you have to pass --enable-gui=gtk3 620explicitly to configure, and avoid passing --enable-gnome-check to that, as 621the functionality of the GNOME 2 support has already been consolidated in 622GTK+ 3. 623 624Otherwise, if you are using Motif or Athena, when you have the Motif or Athena 625files in a directory where configure doesn't look, edit the Makefile to enter 626the names of the directories. Search for "GUI_INC_LOC" for an example to set 627the Motif directories, "CONF_OPT_X" for Athena. 628 629 *gui-x11-gtk* 630Currently, Vim supports both GTK+ 2 and GTK+ 3. 631 632The GTK+ 2 GUI requires GTK+ 2.2 or later. 633 634Although the GTK+ 3 GUI is written in such a way that the source code can be 635compiled against all versions of the 3.x series, we recommend GTK+ 3.10 or 636later because of its substantial implementation changes in redraw done at 637that version. 638 639 *gui-x11-motif* 640For Motif, you need at least Motif version 1.2 and/or X11R5. Motif 2.0 and 641X11R6 are OK. Motif 1.1 and X11R4 might work, no guarantee (there may be a 642few problems, but you might make it compile and run with a bit of work, please 643send me the patches if you do). The newest releases of LessTif have been 644reported to work fine too. 645 646 *gui-x11-athena* 647The Athena version uses the Xaw widget set by default. If you have the 3D 648version, you might want to link with Xaw3d instead. This will make the 649menus look a bit better. Edit the Makefile and look for "XAW_LIB". The 650scrollbars will remain the same, because Vim has its own, which are already 6513D (in fact, they look more like Motif). 652 653 *gui-x11-neXtaw* 654The neXtaw version is mostly like Athena, but uses different widgets. 655 656 *gui-x11-misc* 657In general, do not try to mix files from different GTK+, Motif, Athena and X11 658versions. This will cause problems. For example, using header files for 659X11R5 with a library for X11R6 probably doesn't work (although the linking 660won't give an error message, Vim will crash later). 661 662============================================================================== 6639. X11 selection mechanism *x11-selection* 664 665If using X11, in either the GUI or an xterm with an X11-aware Vim, then Vim 666provides varied access to the X11 selection and clipboard. These are accessed 667by using the two selection registers "* and "+. 668 669X11 provides two basic types of global store, selections and cut-buffers, 670which differ in one important aspect: selections are "owned" by an 671application, and disappear when that application (e.g., Vim) exits, thus 672losing the data, whereas cut-buffers, are stored within the X-server itself 673and remain until written over or the X-server exits (e.g., upon logging out). 674 675The contents of selections are held by the originating application (e.g., upon 676a copy), and only passed on to another application when that other application 677asks for them (e.g., upon a paste). 678 679The contents of cut-buffers are immediately written to, and are then 680accessible directly from the X-server, without contacting the originating 681application. 682 683 *quoteplus* *quote+* 684There are three documented X selections: PRIMARY (which is expected to 685represent the current visual selection - as in Vim's Visual mode), SECONDARY 686(which is ill-defined) and CLIPBOARD (which is expected to be used for 687cut, copy and paste operations). 688 689Of these three, Vim uses PRIMARY when reading and writing the "* register 690(hence when the X11 selections are available, Vim sets a default value for 691|'clipboard'| of "autoselect"), and CLIPBOARD when reading and writing the "+ 692register. Vim does not access the SECONDARY selection. 693 694Examples: (assuming the default option values) 695- Select a URL in Visual mode in Vim. Go to your browser and click the 696 middle mouse button in the URL text field. The selected text will be 697 inserted (hopefully!). Note: in Firefox you can set the 698 middlemouse.contentLoadURL preference to true in about:config, then the 699 selected URL will be used when pressing middle mouse button in most places 700 in the window. 701- Select some text in your browser by dragging with the mouse. Go to Vim and 702 press the middle mouse button: The selected text is inserted. 703- Select some text in Vim and do "+y. Go to your browser, select some text in 704 a textfield by dragging with the mouse. Now use the right mouse button and 705 select "Paste" from the popup menu. The selected text is overwritten by the 706 text from Vim. 707Note that the text in the "+ register remains available when making a Visual 708selection, which makes other text available in the "* register. That allows 709overwriting selected text. 710 *x11-cut-buffer* 711There are, by default, 8 cut-buffers: CUT_BUFFER0 to CUT_BUFFER7. Vim only 712uses CUT_BUFFER0, which is the one that xterm uses by default. 713 714Whenever Vim is about to become unavailable (either via exiting or becoming 715suspended), and thus unable to respond to another application's selection 716request, it writes the contents of any owned selection to CUT_BUFFER0. If the 717"+ CLIPBOARD selection is owned by Vim, then this is written in preference, 718otherwise if the "* PRIMARY selection is owned by Vim, then that is written. 719 720Similarly, when Vim tries to paste from "* or "+ (either explicitly, or, in 721the case of the "* register, when the middle mouse button is clicked), if the 722requested X selection is empty or unavailable, Vim reverts to reading the 723current value of the CUT_BUFFER0. 724 725Note that when text is copied to CUT_BUFFER0 in this way, the type of 726selection (character, line or block) is always lost, even if it is a Vim which 727later pastes it. 728 729Xterm, by default, always writes visible selections to both PRIMARY and 730CUT_BUFFER0. When it pastes, it uses PRIMARY if this is available, or else 731falls back upon CUT_BUFFER0. For this reason, when cutting and pasting 732between Vim and an xterm, you should use the "* register. Xterm doesn't use 733CLIPBOARD, thus the "+ doesn't work with xterm. 734 735Most newer applications will provide their current selection via PRIMARY ("*) 736and use CLIPBOARD ("+) for cut/copy/paste operations. You thus have access to 737both by choosing to use either of the "* or "+ registers. 738 739 740 vim:tw=78:sw=4:ts=8:noet:ft=help:norl: 741