usr_09.txt ForVim version 9.2. Last change: 2026 Feb 14 VIM USER MANUALbyBramMoolenaarUsing theGUIVim works in an ordinary terminal, while gVim hasa GraphicalUserInterface(GUI). It cando the same things anda few more. TheGUI offers menus,atoolbar, scrollbars and other items. This chapteris about these extra thingsthat theGUI offers.09.1 Parts of theGUI09.2 Using the mouse09.3 Theclipboard09.4Select mode Next chapter:usr_10.txt Making big changes Previous chapter:usr_08.txt SplittingwindowsTable of contents:usr_toc.txt==============================================================================09.1 Parts of theGUIYou might have an icon on your desktop that starts gvim. Otherwise, one ofthese commands shoulddo it:gvim file.txtvim -g file.txtIf this doesn't work you don't havea version of Vim withGUI support. Youwill have toinstall one first. Vim will openawindow and display "file.txt" in it. What thewindow lookslike depends on the version of Vim. It should resemble the following picture(foras faras this can be shown in ASCII!).+----------------------------------------------------+| file.txt+ (~/dir)- VIMX |<-window title+----------------------------------------------------+| FileEdit ToolsSyntax Buffers Window Help |<- menubar+----------------------------------------------------+| aaa bbb ccc ddd eee fffggg hhh iii jjj |<- toolbar| aaa bbb ccc ddd eee fffggg hhh iii jjj |+----------------------------------------------------+| file text |^ ||~ |# ||~ |# |<- scrollbar|~ |# ||~ |# ||~ |# || |V |+----------------------------------------------------+The largestspaceis occupied by the file text. This shows the file in thesame wayas ina terminal. With some different colors and another fontperhaps.THE WINDOW TITLEAt the very topis thewindow title. Thisis drawn by yourwindow system.Vim will set the title to show the name of the current file. First comes thename of the file. Then some special characters and the directory of the filein parens. These special characters can be present:-The file cannot be modified (e.g.,ahelp file)+The file contains changes=The fileis read-only=+The fileis read-only, contains changes anywayIf nothingis shown you have an ordinary, unchanged file.THE MENUBARYou know howmenus work, right? Vim has the usual items, plusa few more.Browse them to get an idea of what you can use them for.A relevant submenuis Edit/Global Settings. You will find these entries:Toggle Toolbarmake the toolbar appear/disappearToggle Bottom Scrollbarmakea scrollbar appear/disappearat the bottomToggle Left Scrollbarmakea scrollbar appear/disappearat the leftToggle Right Scrollbarmakea scrollbar appear/disappearat the rightOn most systems you can tear-off the menus.Select the top item of the menu,the one that looks likea dashed line. You will geta separatewindow withthe items of the menu. It will hang around until you close the window.THE TOOLBARThis contains icons for the most often used actions. Hopefully the icons areself-explanatory. There aretooltips to get an extra hint (move the mousepointer to the icon without clicking and don't moveit fora second).The "Edit/Global Settings/Toggle Toolbar" menu item can be used to make thetoolbar disappear. If you never wanta toolbar, use this command in yourvimrc file::set guioptions-=TThis removes the 'T' flag from the'guioptions' option. Other parts of theGUI can also be enabled or disabled with this option. See thehelp for it.THE SCROLLBARSBy default thereis one scrollbar on the right. It does the obvious thing.When you split the window, eachwindow will get its own scrollbar. You can makea horizontal scrollbar appear with the menu itemEdit/Global Settings/Toggle Bottom Scrollbar. Thisis useful indiff mode, orwhen the'wrap' option has been reset (more about that later).When there are vertically split windows, only thewindows on the right sidewill havea scrollbar. However, when you move the cursor toawindow on theleft,it will be this one that the scrollbar controls. This takesa bit oftime to get used to. When you work with vertically split windows, consider addinga scrollbar onthe left. This can be done witha menu item, or with the'guioptions' option::set guioptions+=lThis adds the 'l' flag to'guioptions'.==============================================================================09.2 Using the mouseStandards are wonderful. In Microsoft Windows, you can use the mouse toselect text ina standard manner. TheX Window system also hasa standardsystem for using the mouse. Unfortunately, these two standards are not thesame. Fortunately, you can customize Vim. You can make the behavior of the mousework like anX Window system mouse ora Microsoft Windows mouse. Thefollowing command makes the mouse behave like anX Window mouse::behave xtermThe following command makes the mouse work likea Microsoft Windows mouse::behave mswinThe default behavior of the mouse on UNIX systemsis xterm. The defaultbehavior ona Microsoft Windows systemis selected during the installationprocess. For details about what the two behaviors are, see:behave. Herefollowsa summary.XTERM MOUSE BEHAVIORLeft mouse clickposition the cursorLeft mouse dragselect text inVisual modeMiddle mouse clickpaste text from theclipboardRight mouse clickextend the selected text until the mousepointerMSWIN MOUSE BEHAVIORLeft mouse clickposition the cursorLeft mouse dragselect text inSelect mode (see09.4)Left mouse click, with Shiftextend the selected text until the mousepointerMiddle mouse clickpaste text from theclipboardRight mouse clickdisplaya pop-up menuThe mouse can be further tuned. Check out theseoptions if you want to changethe way how the mouse works:'mouse'in which mode the mouseis used by Vim'mousemodel'what effecta mouse click has'mousetime'time between clicks foradouble-click'mousehide'hide the mouse while typing'selectmode'whether the mouse startsVisual orSelect mode==============================================================================09.3 TheclipboardInsection04.7 the basic use of theclipboard was explained. Thereis oneessential thing to explain about X-windows: There are actually two places toexchange text between programs.MS-Windows doesn't have this.In X-Windows thereis the "current selection". Thisis the text thatiscurrently highlighted. In Vim thisis theVisual area (this assumes you areusing the default option settings). You can paste this selection in anotherapplication without any further action. For example, in this text selecta few words with the mouse. Vim willswitch toVisual mode and highlight the text. Now start another gvim, withouta file name argument, so thatit displays an empty window. Click the middlemouse button. The selected text will be inserted.The "current selection" will only remain valid until some other textisselected. After doing the paste in the other gvim, now select some charactersin that window. You will notice that the words that were previously selectedin the othergvimwindow are displayed differently. This means thatit nolongeris the current selection.You don't need to select text with the mouse, using the keyboard commands forVisual mode works justas well.THE REAL CLIPBOARDNow for the other place with which text can be exchanged. We call this the"realclipboard", to avoid confusion. Often both the "current selection" andthe "realclipboard" are called clipboard, you'll have to get used to that. Toput text on the real clipboard, selecta few different words in one ofthe gvims you have running. Then use the Edit/Copy menu entry. Now the texthas been copied to the real clipboard. You can't see this, unless you havesome application that shows theclipboard contents (e.g., KDE's Klipper). Now select the other gvim, position the cursor somewhere and use theEdit/Paste menu. You will see the text from the realclipboardis inserted.USING BOTHThis use of both the "current selection" and the "realclipboard" might sounda bit confusing. Butitis very useful. Let's show this with an example.Use onegvim witha text file and perform these actions:-Select two words inVisual mode.- Use the Edit/Copy menu to get these words onto the clipboard.-Select one otherword inVisual mode.- Use the Edit/Paste menu item. What will happenis that the single selectedwordis replaced with the two words from the clipboard.- Move the mouse pointer somewhere else and click the middle button. You will see that theword you just overwrote with theclipboardis inserted here.If you use the "current selection" and the "realclipboard" with care, you candoa lot of useful editing with them.USING THE KEYBOARDIf you don't like using the mouse, you can access the current selection andthe realclipboard with two registers. The "* registeris for the currentselection. To make text become the current selection, useVisual mode. For example,to selecta whole line just press "V". Toinsert the current selection before the cursor:"*PNotice theuppercase "P". Thelowercase "p" puts the text after the cursor.The "+ registeris used for the real clipboard. For example, to copy the textfrom the cursor position until theend of the line to the clipboard:"+y$Remember, "y"is yank, whichis Vim's copy command. Toinsert the contents of the realclipboard before the cursor:"+PIt's the sameas for the current selection, but uses the plus (+) registerinstead of thestar(*) register.==============================================================================09.4Select modeAnd now something thatis used more often onMS-Windows than on X-Windows.But both cando it. You already know aboutVisual mode.Select modeis likeVisual mode, becauseitis also used to select text. But thereis an obviousdifference: When typing text, the selected textis deleted and the typed textreplaces it.To start working withSelect mode, youmust first enableit (forMS-Windowsitis probably already enabled, but you cando this anyway)::set selectmode+=mouseNow use the mouse to select some text. Itis highlighted like inVisual mode.Now pressa letter. The selected textis deleted, and the singleletterreplaces it. You are inInsert mode now, thus you can continue typing.Since typing normal text causes the selected text to be deleted, you can notuse the normalmovement commands "hjkl", "w", etc. Instead, use the shiftedfunction keys.<S-Left> (shifted cursor left key) moves the cursor left. Theselected textis changed like inVisual mode. The other shifted cursor keysdo what you expect.<S-End> and<S-Home> also work.You can tune the waySelect mode works with the'selectmode' option.==============================================================================Next chapter:usr_10.txt Making big changesCopyright: seemanual-copyright vim:tw=78:ts=8:noet:ft=help:norl: