usr_09.txt 10 KB

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