Movatterモバイル変換


[0]ホーム

URL:


Quick links:help overview ·quick reference ·user manual toc ·reference manual toc·faq
Go to keyword (shortcut:k)
Site search (shortcut:s)
gui_x11.txt   ForVim version 9.1.  Last change: 2024 Nov 17VIM REFERENCE MANUAL    by Bram MoolenaarVim's GraphicalUserInterfacegui-x11GUI-X11Motif1. Starting theX11GUIgui-x11-start2.GUI Resourcesgui-resources3. Shell Commandsgui-pty4. Variousgui-x11-various5.GTK versiongui-gtk6.GNOME versiongui-gnome7.KDE versiongui-kde8. Compilinggui-x11-compiling9.X11 selection mechanismx11-selectionOther relevant documentation:gui.txt  For generic items of the GUI.==============================================================================1. Starting theX11GUIgui-x11-startE665Then you can run theGUI version of Vim in either of these ways:gvim[options] [files...]    vim-g[options] [files...]So if you call the executable "gvim", or make "gvim"a link to the executable,then theGUI version will automatically be used.  Additional characters may beadded after "gvim", for example "gvim-5".You may also start up theGUI from within theterminal version by using one ofthese commands::gui[++opt][+cmd] [-f|-b] [files...]:gu:gui:gvim[++opt][+cmd] [-f|-b] [files...]:gv:gvimThe "-f" option runs Vim in the foreground.The "-b" option runs Vim in the background (thisis the default).Also see++opt and+cmd.gui-forkWhen theGUIis started,it doesa fork() and exits the current process.Whengvim was started froma shell this makes the shell accept furthercommands.  If you don't want this (e.g. when usinggvim fora mail programthat waits forgvim to exit), startgvim with "gvim-f", "vim -gf" or use":gui-f".  Don't use "vim-fg", because "-fg"specifies the foregroundcolor.When using "vim-f" and then ":gui", Vim will run in the foreground.  The"-f" argument will be remembered.  To force running Vim in the background use":gui-b"."gvim--nofork" does the sameas "gvim-f".When there are running jobs Vim will not fork, because the processes would nolonger be child processes.E851E852Whenstarting theGUI fails Vim will try to continue running in the terminal.If you want theGUI to run in the foreground always, include the 'f'flag in'guioptions'.-f.==============================================================================2.GUI Resourcesgui-resources.XdefaultsIf using theMotif version of theGUI (not for the KDE,GTK+ orWin32version),a number ofX resources are available.  You should use Vim'sclass"Vim" when setting these.  They areas follows:    Resource nameMeaning    reverseVideoBoolean: should reverse video be used?    backgroundColor of background.    foregroundColor of normal text.    scrollBackgroundColor of trough portion of scrollbars.    scrollForegroundColor of slider and arrow portions of scrollbars.    menuBackgroundColor of menu backgrounds.    menuForegroundColor of menu foregrounds.    tooltipForegroundColor of tooltip and balloon foreground.    tooltipBackgroundColor of tooltip and balloon background.    fontName of font used for normal text.    boldFontName of font used forbold text.    italicFontName of font used foritalic text.    boldItalicFontName of font used for bold,italic text.    menuFontName of font used for the menus, used when compiledwithout the+xfontset feature    menuFontSetName offontset used for the menus, used when compiledwith the+xfontset feature    tooltipFontName of the font used for the tooltip and balloons.When compiled with the+xfontset feature thisisafontset name.    geometryInitial geometry to use for gvim'swindow (defaultis same sizeasterminal that started it).    scrollbarWidthThickness of scrollbars.    borderWidthThickness of border around text area.A special font for italic, bold, and italic-bold text will only be used ifthe user has specified one viaa resource.  No attemptis made to guess whatfonts should be used for these based on the normal text font.Note that the colors can also be set with the ":highlight" command, using the"Normal", "Menu", "Tooltip", and "Scrollbar" groups.  Example::highlight Menu guibg=lightblue:highlight Tooltip guibg=yellow:highlight Scrollbar guibg=lightblue guifg=blue:highlight Normal guibg=grey90font-sizesNote: All fonts (except for the menu and tooltip)must be of the same size!!!If you don'tdo this, text will disappear or mess up the display.  Vim doesnot check the font sizes.  It's the size in screen pixels thatmust be thesame.Note that some fonts that have the same point size don't have the samepixel size!  Additionally, the positioning of the fontsmust be the same(ascent and descent).  You can check this with "xlsfonts-l{fontname}".If any of these things are also set with Vim commands, e.g. with":set guifont=Screen15", then this will override theX resources (currently'guifont'is the only option thatis supported).Hereis an example of what you mightput in your ~/.Xdefaults file:Vim*useSchemes:allVim*sgiMode:trueVim*useEnhancedFSB:trueVim.foreground:BlackVim.background:WheatVim*fontList:7x13The first three of these are standard resources on Silicon Graphics machineswhich makeMotif applications look even better, highly recommended!The "Vim*fontList"is to set the menu font for Motif.  Example:Vim*menuBar*fontList:     -*-courier-medium-r-*-*-10-*-*-*-*-*-*-*NOTE:A more portable, and indeed more correct, way to specify the menu fontinMotifis through the resource:Vim.menuFont:     -*-courier-medium-r-*-*-10-*-*-*-*-*-*-*Or, when compiled with the+xfontset feature:Vim.menuFontSet:     -*-courier-medium-r-*-*-10-*-*-*-*-*-*-*Don't use "Vim*geometry" in the defaults.  This will break the menus.  Use"Vim.geometry" instead.If you get an error message "Cannot allocate colormap entry for "gray60",try adding this to your Vim resources (change the colors to your liking):Vim*scrollBackground:BlackVim*scrollForeground:BlueThe resources can also be set with arguments to Vim:    argumentmeaning-gui-display{display}Run vim on{display}-display-iconicStart vim iconified-iconic-background{color}Use{color} for the background-background-bg{color}idem-bg-foreground{color}Use{color} for normal text-foreground-fg{color}idem-fg-ul{color}idem-ul-font{font}Use{font} for normal text-font-fn{font}idem-fn-boldfont{font}Use{font} forbold text-boldfont-italicfont{font}Use{font} foritalic text-italicfont-menufont{font}Use{font} for menu items-menufont-menufontset{fontset} Use{fontset} for menu items-menufontset-mf{font}idem-mf-geometry{geom}Use{geom} for initial geometry-geometry-geom{geom}idem, see-geometry-example-geom-borderwidth{width}Usea border width of{width}-borderwidth-bw{width}idem-bw-scrollbarwidth-scrollbarwidth{width}Usea scrollbar width of{width}-sw{width}idem-sw-menuheight{height}Usea menubar height of{height}-menuheight-mh{height}idem-mhNOTE: OnMotif the valueis ignored, the menu heightis computed to fit the menus.-reverseUse reverse video-reverse-rvidem-rv   +reverseDon't use reverse video-+reverse   +rvidem-+rv-xrm{resource}Set the specified resource-xrmNote about reverse video: Vim checks that the resultis actuallya light textona dark background.  The reasonis that someX11 versions swap the colors,and some don't.  These two examples will both give yellow text ona bluebackground:gvim-fg Yellow-bg Blue-reversegvim-bg Yellow-fg Blue-reverse-geometry-exampleAn example for the geometry argument:gvim -geometry 80x63+8+100This createsawindow with 80 columns and 63 linesat position 8 pixels fromthe left and 100 pixels from the top of the screen.==============================================================================3. Shell Commandsgui-ptyWARNING: Executing an external command from theGUI will not always work."normal" commands like "ls", "grep" and "make" mostly work fine.  Commandsthat require an intelligentterminal like "less" and "ispell" won't work.Some may even hang and need to be killed from another terminal.  So becareful!There are two ways todo the I/O witha shell command: Pipes anda pseudo-tty.The defaultis to usea pseudo-tty.  This should work best on most systems.Unfortunately, the implementation of the pseudo-ttyis different on everyUnixsystem.  And some systems require root permission.  To avoid running intoproblems witha pseudo-tty when you least expect it, testit when not editinga file.  Be prepared to "kill" the started command or Vim.  Commands like":r !cat" may hang!If usinga pseudo-tty does not work for you, reset the'guipty' option::set noguiptyUsinga pipe should work on anyUnix system, but there are disadvantages:- Some shell commands will notice thata pipeis being used and behave  differently.  E.g., ":!ls" willlist the files in one column.- The ":sh" command won't showa prompt, althoughit will sort of work.- When using ":make" it's not possible to interrupt withaCTRL-C.Typeahead while the external commandis runningis often lost.  This happensboth witha pipe anda pseudo-tty.  Thisisa known problem, butit seemsitcan't be fixed (orat least, it's very difficult).gui-pty-eraseWhen your erase characteris wrong for an external command, you should fixthis in your "~/.cshrc" file, or whatever file your shell uses forinitializations.  For example, when you want to usebackspace to deletecharacters, but hitting backspaces produces "^H" instead, try adding this toyour "~/.cshrc":stty erase ^HThe ^Hisa realCTRL-H, typeitasCTRL-VCTRL-H.==============================================================================4. Variousgui-x11-variousgui-x11-printingThe "File/Print" menu simply sends the current buffer to "lpr".  Nooptions orwhatever.  If you want something else, you can define your own print command.For example:  :10amenu File.Print :w !lpr -Php3  :10vmenu File.Print :w !lpr -Php3X11-iconVim usesa black&white icon by default when compiled with Motif.Acolored Vim iconis includedas $VIMRUNTIME/vim32x32.xpm.  For GTK+, thisisthe builtin icon used.  Unfortunately, how you shouldinstallit depends onyourwindow manager.  When you use this, remove the 'i' flag from'guioptions', to remove the black&white icon:  :set guioptions-=iIf you use one of the fvwm* family ofwindow managers simply add this line toyour .fvwm2rc configuration file:  Style "vim"Icon vim32x32.xpmMake sure the icon file's locationis consistent with thewindow manager'sImagePath statement.  Either modify the ImagePath from within your .fvwm2rc ordrop the icon into one the pre-defined directories:  ImagePath /usr/X11R6/include/X11/pixmaps:/usr/X11R6/include/X11/bitmapsNote: older versions of fvwm use "IconPath" instead of "ImagePath".For CDE "dtwm" (a derivative of Motif) add this line in the .Xdefaults:   Dtwm*Vim*iconImage: /usr/local/share/vim/vim32x32.xpmFor "mwm" (Motifwindow manager) the line would be:   Mwm*Vim*iconImage: /usr/local/share/vim/vim32x32.xpmMouse Pointers Available in X11X11_mouse_shapesBy using the'mouseshape' option, the mouse pointer can be automaticallychanged whenever Vim enters one of itsvarious modes (e.g.,Insert orCommand).  Currently, the available pointers are:arrowan arrow pointing northwestbeama I-like verticalbarsizean arrow pointing up and downbusya wristwatchblankan invisible pointercrosshaira thin "+" signhand1a dark hand pointing northeasthand2a light hand pointing northwestpencila pencil pointing southeastquestionquestion_arrowright_arrowan arrow pointing northeastup_arrowan arrow pointing upwardsAdditionally, any of the mouse pointers that are built intoX11 may beused by specifying an integer from the X11/cursorfont.h include file.Ifa nameis used that exists on other systems, but not in X11, the default"arrow" pointeris used.==============================================================================5.GTK versiongui-gtkGTK+GTKGTK3TheGTK version of theGUI worksa little bit different.GTK does _not_ use the traditionalX resource settings.  Thus items in your~/.Xdefaults or app-defaults files are not used.Many of the traditionalX command line arguments are not supported.  (e.g.,stuff like -bg, -fg, etc).  The ones that are supported are:    command line argument   resource namemeaning-fn  or-font    .fontfont name for the text-geom  or-geometry    .geometrysize of thegvimwindow-rv  or-reverse    *reverseVideowhite text on black background-displaydisplay to be used-fg-foreground{color}foreground color-bg-background{color}background colorTo set the font, see'guifont'.  For GTK, there's alsoa menu option thatdoes this.Additionally, there are these command line arguments, which are handled byGTKinternally.  Look in theGTK documentation for how they are used:--sync--gdk-debug--gdk-no-debug--no-xshm(not inGTK+ 2)--xim-preedit(not inGTK+ 2)--xim-status(not inGTK+ 2)--gtk-debug--gtk-no-debug--g-fatal-warnings--gtk-module--display(GTK+ counterpart of -display; works the same way.)--screen(The screen number; forGTK+ 2.2 multihead support.)These arguments are ignored when the+netbeans_intg featureis used:-xrm-mfAs for colors, Vim's color settings (forsyntax highlighting)is stilldone the traditional Vim way.  See:highlight for more help.If you want to set the colors of remaininggui components (e.g., themenubar, scrollbar, whatever), those areGTK specific settings and youneed to set those up in some sort of gtkrc file.  You'll have to referto theGTK documentation, however little there is, on how todo this.Seehttp://developer.gnome.org/doc/API/2.0/gtk/gtk-Resource-Files.htmlfor more information.gtk3-slowIf you are usingGTK3 and Vim appears to be slow, try setting the environmentvariable $GDK_RENDERING to "image".Tooltip Colorsgtk-tooltip-colorsExample, which sets the tooltip colors to black on light-yellow:style "tooltips"{bg[NORMAL] = "#ffffcc"fg[NORMAL] = "#000000"}widget "gtk-tooltips*"style "tooltips"Write this in the file ~/.gtkrc andit will be used by GTK+.  ForGTK+ 2you might have to use the file ~/.gtkrc-2.0 instead, depending on yourdistribution.ForGTK+ 3, an effect similar to the above can be obtained by adding thefollowing snippet of CSS code to $XDG_HOME_DIR/gtk-3.0/gtk.css (see the nextsection):ForGTK+ 3< 3.20:.tooltip {background-color: #ffffcc;color: #000000;}ForGTK+ 3 >= 3.20:tooltip {    background-color: #ffffcc;    text-shadow: none;}tooltip label {    color: #2e3436;}A Quick Look at GTK+ CSSgtk-cssThe contents of this subsection apply toGTK+ 3.20 or later which providesstable support forGTK+ CSS:https://developer.gnome.org/gtk3/stable/theming.htmlGTK+ uses CSS for styling and layout of widgets.  In this subsection, we'llhavea quick lookatGTK+ CSS through simple, illustrative examples.You can usually edit the config with:vim $HOME/.config/gtk-3.0/gtk.cssExample 1.  Empty Space AdjustmentBy default, the toolbar and the tabline of theGTK+ 3GUI are somewhat largerthan those of theGTK+ 2 GUI.  Some people may want to make them look similarto theGTK+ 2GUI in size.Todo that, we'll try reducing emptyspace around icons and labels that looksapparently superfluous.Add the following lines to $XDG_HOME_DIR/gtk-3.0/gtk.css (usually,$HOME/.config/gtk-3.0/gtk.css):toolbar button {    margin-top: -2px;    margin-right: 0px;    margin-bottom: -2px;    margin-left: 0px;    padding-top: 0px;    padding-right: 0px;    padding-bottom: 0px;    padding-left: 0px}notebook tab {    margin-top: -1px;    margin-right: 3px;    margin-bottom: -1px;    margin-left: 3px;    padding-top: 0px;    padding-right: 0px;    padding-bottom: 0px;    padding-left: 0px}Since it'sa CSS, they can be rewritten using shorthand:toolbar button {    margin: -2px 0px;    padding: 0px;}notebook tab {    margin: -1px 3px;    padding: 0px}Note: You might want to use'toolbariconsize' to adjust the icon size, too.Note: Depending on the icon theme and/or the font in use, some extra tweaksmay be needed fora satisfactory result.Note: In addition to margin and padding, you can use border.  For details,refer to the box model of CSS, e.g.,https://www.w3schools.com/css/css_boxmodel.aspExample 2.  More Than Just ColorsGTK+ CSS supports gradientsas well:tooltip {    background-image: -gtk-gradient(linear,    0 0, 0 1,    color-stop(0, #344752),    color-stop(0.5, #546772),    color-stop(1, #243742));}tooltip label {    color: #f3f3f3;}Gradients can be used to makeaGUI element visually distinguishable fromothers without relying on high contrast. Accordingly, effective use of themisa useful technique to givea themea sense of unity in color and luminance.Note: Theming can be difficult sinceitmust make every application lookequally good; makinga single application more charming often gets othersunexpectedlyless attractive or even deteriorates their usability.  Keep thisin mind always when you try improvinga theme.Example 3.  border colorTo eliminate borders when maximized:    @define-color bg_color #1B2B34;    #vim-main-window {background-color: @bg_color;    }Using Vim as a GTK+ plugingui-gtk-socketidWhen theGTK+ version of Vim starts up normally,it creates its own top levelwindow (technically,a 'GtkWindow').GTK+ provides an embedding facility withits GtkSocket and GtkPlug widgets.  If oneGTK+ application createsaGtkSocket widget in one of its windows, an entirely differentGTK+ applicationmay embed itself into the first application by creatinga top-level GtkPlugwidget using the socket's ID.If you pass Vim the command-line option '--socketid' witha decimal orhexadecimal value, Vim will createa GtkPlug widget using that value insteadof the normal GtkWindow.  This enables Vim to actasaGTK+ plugin.This reallyisa programmer's interface, andis of no use withouta supportingapplication to spawn the Vim correctly.  For more details onGTK+ sockets, seehttp://www.gtk.org/api/Note that this feature requires the latestGTK version.GTK 1.2.10 still hasa small problem.  The socket feature has not yet been tested withGTK+ 2--feel free to volunteer.==============================================================================6.GNOME versiongui-gnomeGnomeGNOMETheGNOMEGUI works just like theGTK+ version.  SeeGTK+ above for howitworks.  It looksa bit different though, andimplements one important featurethat's not available in the plainGTK+ GUI:  Interaction with the sessionmanager.gui-gnome-sessionThese are the different looks:- UsesGNOME dialogs (GNOME 1 only).  TheGNOME 2GUI uses the same nice  dialogsas theGTK+ 2 version.- Uses theGNOME dock, so that the toolbar and menubar can be moved to  different locations other than the top (e.g., the toolbar can be placed on  the left, right, top, or bottom).  The placement of the menubar and  toolbaris only saved in theGNOME 2 version.- That means the menubar and toolbar handles are back!  Yeah!  And the  resizing grid still works too.GNOMEis compiled with ifit was found by configure and the--enable-gnome-check argument was used.Note: Avoid use of --enable-gnome-check withGTK+ 3GUI build.  Thefunctionality mentioned aboveis consolidated inGTK+ 3.GNOME session supportgui-gnome-sessiongnome-sessionOn logout, Vim shows the well-known exit confirmationdialog if anybuffersare modified.  Clicking[Cancel] will stop the logout process.  Otherwise thecurrent sessionis stored to disk by using the:mksession command, andrestored the next time you log in.TheGNOME session support should also work with theKDE session manager.If you are experiencing any problems please report themas bugs.Note: The automatic session save works entirely transparent, in order toavoid conflicts with your own session files, scripts and autocommands.  Thatmeans in detail:- The session fileis stored toa separate directory (usually $HOME/.gnome2).-'sessionoptions'is ignored, anda hardcoded set of appropriate flagsis  used instead:blank,curdir,folds,globals,help,options,tabpages,winsize- The internal variablev:this_sessionis not changed when storing the  session.  Also,itis restored to its old value when logging in again.The position and size of theGUIwindowis not saved by Vim since doing sois thewindow manager's job.  But if compiled withGTK+ 2 support, Vim helpsthe WM to identify thewindow by restoring thewindow role (using the--rolecommand line argument).==============================================================================7.KDE versiongui-kdekdeKDEKVimgui-x11-kdeThereis noKDE version of Vim.  There has been some work ona port using theQt toolkit, butit never worked properly andit has been abandoned.  Workcontinues on Yzis:https://github.com/chrizel/Yzis butit seems alsoabandoned.==============================================================================8. Compilinggui-x11-compilingIf using X11, Vim's configure will by default first try to find the necessaryGTK+ files on your system.  When bothGTK+ 2 andGTK+ 3 are available,GTK+ 2will be chosen unless --enable-gui=gtk3is passed explicitly to configure.If theGTK+ files cannot be found, then theMotif files will be searched for.If both fail, theGUI will be disabled.For GTK+, Vim's configuration process uses pkg-config(1) to check if theGTK+ required fora specified buildis properly installed and usable.Accordingly,itisa good idea to make sure before running configure thatyour system hasa working pkg-config together with the .pc file of therequired GTK+.  For that, say, run the following on the command line to see ifyour pkg-config works with yourGTK+ 2:    $ pkg-config --modversion gtk+-2.0Replace gtk+-2.0 with gtk+-3.0 forGTK+ 3. If you get the correct versionnumber of your GTK+, you can proceed; if not, you probably need todo somesystem administration chores to set up pkg-config andGTK+ correctly.TheGTK+ 2GUIis built by default.  Therefore, you usually don't need to passanyoptions suchas --enable-gui=gtk2 to configure and build that.Optionally, theGTK+ 2GUI can consolidate theGNOME 2 support.  This supportis enabled by passing --enable-gnome-check to configure.If you want to build theGTK+ 3 GUI, you have to pass --enable-gui=gtk3explicitly to configure, and avoid passing --enable-gnome-check to that,asthe functionality of theGNOME 2 support has already been consolidated inGTK+ 3.Otherwise, if you are using Motif, when you have theMotif files inadirectory where configure doesn't look, edit the Makefile to enter the namesof the directories.  Search for "GUI_INC_LOC" for an example to settheMotif directories.gui-x11-gtkCurrently, Vim supports bothGTK+ 2 andGTK+ 3.TheGTK+ 2GUI requiresGTK+ 2.2 or later.Although theGTK+ 3GUIis written in sucha way that the source code can becompiled against all versions of the 3.x series, we recommendGTK+ 3.10 orlater because of its substantial implementation changes in redraw doneatthat version.gui-x11-motifFor Motif, you needat leastMotif version 1.2 and/or X11R5.Motif 2.0 andX11R6 are OK.Motif 1.1 and X11R4 might work, no guarantee (there may beafew problems, but you might makeit compile and run witha bit of work, pleasesend patches if you do).  The newest releases of LessTif have been reported towork fine too.gui-x11-athenagui-x11-neXtawSupport for the AthenaGUI and neXtaw was removed in patch 8.2.4677.gui-x11-miscIn general,do not try to mix files from different GTK+,Motif andX11versions.  This will cause problems.  For example, using header files forX11R5 witha library for X11R6 probably doesn't work (although the linkingwon't give an error message, Vim will crash later).gui-waylandInitial support for the Wayland display server protocol has landed in patch9.1.0064. To enable it, you need to set the environment variable"$GVIM_ENABLE_WAYLAND" in your shell.Note: The Wayland protocolis subject to some restrictions, so the followingfunctions won't work:getwinpos(),getwinposx(),getwinposy() and thev:windowid variable won't be available.==============================================================================9.X11 selection mechanismx11-selectionIf using X11, in either theGUI or an xterm with an X11-aware Vim, then Vimprovides varied access to theX11 selection and clipboard.  These are accessedby using the two selectionregisters "* and "+.X11 provides two basic types of global store, selections and cut-buffers,which differ in one important aspect: selections are "owned" by anapplication, and disappear when that application (e.g., Vim) exits, thuslosing the data, whereas cut-buffers, are stored within the X-server itselfand remain until written over or the X-server exits (e.g., upon logging out).The contents of selections are held by the originating application (e.g., upona copy), and only passed on to another application when that other applicationasks for them (e.g., upona paste).The contents of cut-buffers are immediately written to, and are thenaccessible directly from the X-server, without contacting the originatingapplication.quoteplusquote+There are three documentedX selections: PRIMARY (whichis expected torepresent the current visual selection-as in Vim'sVisual mode), SECONDARY(whichis ill-defined) and CLIPBOARD (whichis expected to be used forcut, copy and paste operations).Of these three, Vim uses PRIMARY when reading andwriting the "*register(hence when theX11 selections are available, Vim setsa default value for'clipboard' of "autoselect"), and CLIPBOARD when reading andwriting the "+register.  Vim does not access the SECONDARY selection.This applies both to theGUI and theterminal version.  For non-X11 systemsthe plus and thestarregister both use the system clipboard.Examples: (assuming the default option values)-Selecta URL inVisual mode in Vim.  Go to your browser and click the  middle mouse button in the URL text field.  The selected text will be  inserted (hopefully!).Note: in Firefox you can set the  middlemouse.contentLoadURL preference totrue in about:config, then the  selected URL will be used when pressing middle mouse button in most places  in the window.-Select some text in your browser by dragging with the mouse.  Go to Vim and  press the middle mouse button: The selected textis inserted.-Select some text in Vim anddo "+y.  Go to your browser, select some text ina textfield by dragging with the mouse.  Now use the right mouse button and  select "Paste" from thepopup menu.  The selected textis overwritten by the  text from Vim.Note that the text in the "+register remains available when makingaVisualselection, which makes other text available in the "* register.  That allowsoverwriting selected text.W23When you are yanking into the "* or "+register and Vim cannot establishaconnection to theX11 selection (or clipboard),it will useregister0 andoutputa warning:  Warning: Clipboard register not available, using register 0W24Vim comes in different flavors, froma tiny build, that just tries to becompatible to original Vi, to enhanced builds which include many improvements(likea GUI).  However, on servers and embedded systems, Vimis typicallycompiled withoutclipboard support, since this feature requiresX11 librariesto be present.  Check the ":version" output for the flag+clipboard or-clipboard.  The former meansclipboard supportis present while the lattermeans your Vim does not containclipboard support.In thecase when you are trying to access the "* or "+register and Vim hasnoclipboard support, you will see this warning:  Warning: Clipboard register not available. See :h W24If you havea vim with noclipboard support but would like to use theclipboard, try toinstalla more enhanced Vim package like vim-enhanced orvim-gtk3 (theguipackages usually also come withaterminal Vim that hasclipboard support included).x11-cut-bufferThere are, by default, 8 cut-buffers: CUT_BUFFER0 to CUT_BUFFER7.  Vim onlyuses CUT_BUFFER0, whichis the one that xterm uses by default.Whenever Vimis about to become unavailable (either viaexiting or becomingsuspended), and thus unable to respond to another application's selectionrequest,it writes the contents of any owned selection to CUT_BUFFER0.  If the"+ CLIPBOARD selectionis owned by Vim, then thisis written in preference,otherwise if the "* PRIMARY selectionis owned by Vim, then thatis written.Similarly, when Vim tries to paste from "* or "+ (either explicitly, or, inthecase of the "* register, when the middle mouse buttonis clicked), if therequestedX selectionis empty or unavailable, Vim reverts to reading thecurrent value of the CUT_BUFFER0.Note that when textis copied to CUT_BUFFER0 in this way, the type ofselection (character, line or block)is always lost, even ifitisa Vim whichlater pastes it.Xterm, by default, always writes visible selections to both PRIMARY andCUT_BUFFER0.  Whenit pastes,it uses PRIMARY if thisis available, or elsefalls back upon CUT_BUFFER0.  For this reason, when cutting and pastingbetween Vim and an xterm, you should use the "* register.  Xterm doesn't useCLIPBOARD, thus the "+ doesn't work with xterm.Most newer applications will provide their current selection via PRIMARY("*)and use CLIPBOARD("+) for cut/copy/paste operations.  You thus have access toboth by choosing to use either of the "* or "+ registers. vim:tw=78:sw=4:ts=8:noet:ft=help:norl:

Quick links:help overview ·quick reference ·user manual toc ·reference manual toc·faq


[8]ページ先頭

©2009-2025 Movatter.jp