gui_x11.txt 29 KB

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