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