1*usr_09.txt* For Vim version 7.3. Last change: 2006 Apr 24 2 3 VIM USER MANUAL - by Bram Moolenaar 4 5 Using the GUI 6 7 8Vim works in an ordinary terminal. GVim can do the same things and a few 9more. The GUI offers menus, a toolbar, scrollbars and other items. This 10chapter is about these extra things that the GUI offers. 11 12|09.1| Parts of the GUI 13|09.2| Using the mouse 14|09.3| The clipboard 15|09.4| Select mode 16 17 Next chapter: |usr_10.txt| Making big changes 18 Previous chapter: |usr_08.txt| Splitting windows 19Table of contents: |usr_toc.txt| 20 21============================================================================== 22*09.1* Parts of the GUI 23 24You might have an icon on your desktop that starts gVim. Otherwise, one of 25these commands should do it: > 26 27 gvim file.txt 28 vim -g file.txt 29 30If this doesn't work you don't have a version of Vim with GUI support. You 31will have to install one first. 32 Vim will open a window and display "file.txt" in it. What the window looks 33like depends on the version of Vim. It should resemble the following picture 34(for as far as this can be shown in ASCII!). 35 36 +----------------------------------------------------+ 37 | file.txt + (~/dir) - VIM X | <- window title 38 +----------------------------------------------------+ 39 | File Edit Tools Syntax Buffers Window Help | <- menubar 40 +----------------------------------------------------+ 41 | aaa bbb ccc ddd eee fff ggg hhh iii jjj | <- toolbar 42 | aaa bbb ccc ddd eee fff ggg hhh iii jjj | 43 +----------------------------------------------------+ 44 | file text | ^ | 45 | ~ | # | 46 | ~ | # | <- scrollbar 47 | ~ | # | 48 | ~ | # | 49 | ~ | # | 50 | | V | 51 +----------------------------------------------------+ 52 53The largest space is occupied by the file text. This shows the file in the 54same way as in a terminal. With some different colors and another font 55perhaps. 56 57 58THE WINDOW TITLE 59 60At the very top is the window title. This is drawn by your window system. 61Vim will set the title to show the name of the current file. First comes the 62name of the file. Then some special characters and the directory of the file 63in parens. These special character can be present: 64 65 - The file cannot be modified (e.g., a help file) 66 + The file contains changes 67 = The file is read-only 68 =+ The file is read-only, contains changes anyway 69 70If nothing is shown you have an ordinary, unchanged file. 71 72 73THE MENUBAR 74 75You know how menus work, right? Vim has the usual items, plus a few more. 76Browse them to get an idea of what you can use them for. A relevant submenu 77is Edit/Global Settings. You will find these entries: 78 79 Toggle Toolbar make the toolbar appear/disappear 80 Toggle Bottom Scrollbar make a scrollbar appear/disappear at the bottom 81 Toggle Left Scrollbar make a scrollbar appear/disappear at the left 82 Toggle Right Scrollbar make a scrollbar appear/disappear at the right 83 84On most systems you can tear-off the menus. Select the top item of the menu, 85the one that looks like a dashed line. You will get a separate window with 86the items of the menu. It will hang around until you close the window. 87 88 89THE TOOLBAR 90 91This contains icons for the most often used actions. Hopefully the icons are 92self-explanatory. There are tooltips to get an extra hint (move the mouse 93pointer to the icon without clicking and don't move it for a second). 94 95The "Edit/Global Settings/Toggle Toolbar" menu item can be used to make the 96toolbar disappear. If you never want a toolbar, use this command in your 97vimrc file: > 98 99 :set guioptions-=T 100 101This removes the 'T' flag from the 'guioptions' option. Other parts of the 102GUI can also be enabled or disabled with this option. See the help for it. 103 104 105THE SCROLLBARS 106 107By default there is one scrollbar on the right. It does the obvious thing. 108When you split the window, each window will get its own scrollbar. 109 You can make a horizontal scrollbar appear with the menu item 110Edit/Global Settings/Toggle Bottom Scrollbar. This is useful in diff mode, or 111when the 'wrap' option has been reset (more about that later). 112 113When there are vertically split windows, only the windows on the right side 114will have a scrollbar. However, when you move the cursor to a window on the 115left, it will be this one the that scrollbar controls. This takes a bit of 116time to get used to. 117 When you work with vertically split windows, consider adding a scrollbar on 118the left. This can be done with a menu item, or with the 'guioptions' option: 119> 120 :set guioptions+=l 121 122This adds the 'l' flag to 'guioptions'. 123 124============================================================================== 125*09.2* Using the mouse 126 127Standards are wonderful. In Microsoft Windows, you can use the mouse to 128select text in a standard manner. The X Window system also has a standard 129system for using the mouse. Unfortunately, these two standards are not the 130same. 131 Fortunately, you can customize Vim. You can make the behavior of the mouse 132work like an X Window system mouse or a Microsoft Windows mouse. The following 133command makes the mouse behave like an X Window mouse: > 134 135 :behave xterm 136 137The following command makes the mouse work like a Microsoft Windows mouse: > 138 139 :behave mswin 140 141The default behavior of the mouse on UNIX systems is xterm. The default 142behavior on a Microsoft Windows system is selected during the installation 143process. For details about what the two behaviors are, see |:behave|. Here 144follows a summary. 145 146 147XTERM MOUSE BEHAVIOR 148 149Left mouse click position the cursor 150Left mouse drag select text in Visual mode 151Middle mouse click paste text from the clipboard 152Right mouse click extend the selected text until the mouse 153 pointer 154 155 156MSWIN MOUSE BEHAVIOR 157 158Left mouse click position the cursor 159Left mouse drag select text in Select mode (see |09.4|) 160Left mouse click, with Shift extend the selected text until the mouse 161 pointer 162Middle mouse click paste text from the clipboard 163Right mouse click display a pop-up menu 164 165 166The mouse can be further tuned. Check out these options if you want to change 167the way how the mouse works: 168 169 'mouse' in which mode the mouse is used by Vim 170 'mousemodel' what effect a mouse click has 171 'mousetime' time between clicks for a double-click 172 'mousehide' hide the mouse while typing 173 'selectmode' whether the mouse starts Visual or Select mode 174 175============================================================================== 176*09.3* The clipboard 177 178In section |04.7| the basic use of the clipboard was explained. There is one 179essential thing to explain about X-windows: There are actually two places to 180exchange text between programs. MS-Windows doesn't have this. 181 182In X-Windows there is the "current selection". This is the text that is 183currently highlighted. In Vim this is the Visual area (this assumes you are 184using the default option settings). You can paste this selection in another 185application without any further action. 186 For example, in this text select a few words with the mouse. Vim will 187switch to Visual mode and highlight the text. Now start another gVim, without 188a file name argument, so that it displays an empty window. Click the middle 189mouse button. The selected text will be inserted. 190 191The "current selection" will only remain valid until some other text is 192selected. After doing the paste in the other gVim, now select some characters 193in that window. You will notice that the words that were previously selected 194in the other gVim window are displayed differently. This means that it no 195longer is the current selection. 196 197You don't need to select text with the mouse, using the keyboard commands for 198Visual mode works just as well. 199 200 201THE REAL CLIPBOARD 202 203Now for the other place with which text can be exchanged. We call this the 204"real clipboard", to avoid confusion. Often both the "current selection" and 205the "real clipboard" are called clipboard, you'll have to get used to that. 206 To put text on the real clipboard, select a few different words in one of 207the gVims you have running. Then use the Edit/Copy menu entry. Now the text 208has been copied to the real clipboard. You can't see this, unless you have 209some application that shows the clipboard contents (e.g., KDE's klipper). 210 Now select the other gVim, position the cursor somewhere and use the 211Edit/Paste menu. You will see the text from the real clipboard is inserted. 212 213 214USING BOTH 215 216This use of both the "current selection" and the "real clipboard" might sound 217a bit confusing. But it is very useful. Let's show this with an example. 218Use one gVim with a text file and perform these actions: 219 220- Select two words in Visual mode. 221- Use the Edit/Copy menu to get these words onto the clipboard. 222- Select one other word in Visual mode. 223- Use the Edit/Paste menu item. What will happen is that the single selected 224 word is replaced with the two words from the clipboard. 225- Move the mouse pointer somewhere else and click the middle button. You 226 will see that the word you just overwrote with the clipboard is inserted 227 here. 228 229If you use the "current selection" and the "real clipboard" with care, you can 230do a lot of useful editing with them. 231 232 233USING THE KEYBOARD 234 235If you don't like using the mouse, you can access the current selection and 236the real clipboard with two registers. The "* register is for the current 237selection. 238 To make text become the current selection, use Visual mode. For example, 239to select a whole line just press "V". 240 To insert the current selection before the cursor: > 241 242 "*P 243 244Notice the uppercase "P". The lowercase "p" puts the text after the cursor. 245 246The "+ register is used for the real clipboard. For example, to copy the text 247from the cursor position until the end of the line to the clipboard: > 248 249 "+y$ 250 251Remember, "y" is yank, which is Vim's copy command. 252 To insert the contents of the real clipboard before the cursor: > 253 254 "+P 255 256It's the same as for the current selection, but uses the plus (+) register 257instead of the star (*) register. 258 259============================================================================== 260*09.4* Select mode 261 262And now something that is used more often on MS-Windows than on X-Windows. 263But both can do it. You already know about Visual mode. Select mode is like 264Visual mode, because it is also used to select text. But there is an obvious 265difference: When typing text, the selected text is deleted and the typed text 266replaces it. 267 268To start working with Select mode, you must first enable it (for MS-Windows 269it is probably already enabled, but you can do this anyway): > 270 271 :set selectmode+=mouse 272 273Now use the mouse to select some text. It is highlighted like in Visual mode. 274Now press a letter. The selected text is deleted, and the single letter 275replaces it. You are in Insert mode now, thus you can continue typing. 276 277Since typing normal text causes the selected text to be deleted, you can not 278use the normal movement commands "hjkl", "w", etc. Instead, use the shifted 279function keys. <S-Left> (shifted cursor left key) moves the cursor left. The 280selected text is changed like in Visual mode. The other shifted cursor keys 281do what you expect. <S-End> and <S-Home> also work. 282 283You can tune the way Select mode works with the 'selectmode' option. 284 285============================================================================== 286 287Next chapter: |usr_10.txt| Making big changes 288 289Copyright: see |manual-copyright| vim:tw=78:ts=8:ft=help:norl: 290