usr_09.txt 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287
  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.
  94. Fortunately, you can customize Vim. You can make the behavior of the mouse
  95. work like an X Window system mouse or a Microsoft Windows mouse. The following
  96. command makes the mouse behave like an X Window mouse: >
  97. :behave xterm
  98. The following command makes the mouse work like a Microsoft Windows mouse: >
  99. :behave mswin
  100. The default behavior of the mouse on Unix systems is xterm. The default
  101. behavior on Windows systems is selected during the installation process. For
  102. details about what the two behaviors are, see |:behave|. Here follows a
  103. summary.
  104. XTERM MOUSE BEHAVIOR
  105. Left mouse click position the cursor
  106. Left mouse drag select text in Visual mode
  107. Middle mouse click paste text from the clipboard
  108. Right mouse click extend the selected text until the mouse
  109. pointer
  110. MSWIN MOUSE BEHAVIOR
  111. Left mouse click position the cursor
  112. Left mouse drag select text in Select mode (see |09.4|)
  113. Left mouse click, with Shift extend the selected text until the mouse
  114. pointer
  115. Middle mouse click paste text from the clipboard
  116. Right mouse click display a pop-up menu
  117. The mouse can be further tuned. Check out these options if you want to change
  118. the way how the mouse works:
  119. 'mouse' in which mode the mouse is used by Vim
  120. 'mousemodel' what effect a mouse click has
  121. 'mousetime' time between clicks for a double-click
  122. 'mousehide' hide the mouse while typing
  123. 'selectmode' whether the mouse starts Visual or Select mode
  124. ==============================================================================
  125. *09.3* The clipboard
  126. In section |04.7| the basic use of the clipboard was explained. There is one
  127. essential thing to explain about X-windows: There are actually two places to
  128. exchange text between programs. MS-Windows doesn't have this.
  129. In X-Windows there is the "current selection". This is the text that is
  130. currently highlighted. In Vim this is the Visual area (this assumes you are
  131. using the default option settings). You can paste this selection in another
  132. application without any further action.
  133. For example, in this text select a few words with the mouse. Vim will
  134. switch to Visual mode and highlight the text. Now start another gvim, without
  135. a file name argument, so that it displays an empty window. Click the middle
  136. mouse button. The selected text will be inserted.
  137. The "current selection" will only remain valid until some other text is
  138. selected. After doing the paste in the other gvim, now select some characters
  139. in that window. You will notice that the words that were previously selected
  140. in the other gvim window are displayed differently. This means that it no
  141. longer is the current selection.
  142. You don't need to select text with the mouse, using the keyboard commands for
  143. Visual mode works just as well.
  144. THE REAL CLIPBOARD
  145. Now for the other place with which text can be exchanged. We call this the
  146. "real clipboard", to avoid confusion. Often both the "current selection" and
  147. the "real clipboard" are called clipboard, you'll have to get used to that.
  148. To put text on the real clipboard, select a few different words in one of
  149. the gvims you have running. Then use the Edit/Copy menu entry. Now the text
  150. has been copied to the real clipboard. You can't see this, unless you have
  151. some application that shows the clipboard contents (e.g., KDE's Klipper).
  152. Now select the other gvim, position the cursor somewhere and use the
  153. Edit/Paste menu. You will see the text from the real clipboard is inserted.
  154. USING BOTH
  155. This use of both the "current selection" and the "real clipboard" might sound
  156. a bit confusing. But it is very useful. Let's show this with an example.
  157. Use one gvim with a text file and perform these actions:
  158. - Select two words in Visual mode.
  159. - Use the Edit/Copy menu to get these words onto the clipboard.
  160. - Select one other word in Visual mode.
  161. - Use the Edit/Paste menu item. What will happen is that the single selected
  162. word is replaced with the two words from the clipboard.
  163. - Move the mouse pointer somewhere else and click the middle button. You
  164. will see that the word you just overwrote with the clipboard is inserted
  165. here.
  166. If you use the "current selection" and the "real clipboard" with care, you can
  167. do a lot of useful editing with them.
  168. USING THE KEYBOARD
  169. If you don't like using the mouse, you can access the current selection and
  170. the real clipboard with two registers. The "* register is for the current
  171. selection.
  172. To make text become the current selection, use Visual mode. For example,
  173. to select a whole line just press "V".
  174. To insert the current selection before the cursor: >
  175. "*P
  176. Notice the uppercase "P". The lowercase "p" puts the text after the cursor.
  177. The "+ register is used for the real clipboard. For example, to copy the text
  178. from the cursor position until the end of the line to the clipboard: >
  179. "+y$
  180. Remember, "y" is yank, which is Vim's copy command.
  181. To insert the contents of the real clipboard before the cursor: >
  182. "+P
  183. It's the same as for the current selection, but uses the plus (+) register
  184. instead of the star (*) register.
  185. ==============================================================================
  186. *09.4* Select mode
  187. And now something that is used more often on MS-Windows than on X-Windows.
  188. But both can do it. You already know about Visual mode. Select mode is like
  189. Visual mode, because it is also used to select text. But there is an obvious
  190. difference: When typing text, the selected text is deleted and the typed text
  191. replaces it.
  192. To start working with Select mode, you must first enable it (for MS-Windows
  193. it is probably already enabled, but you can do this anyway): >
  194. :set selectmode+=mouse
  195. Now use the mouse to select some text. It is highlighted like in Visual mode.
  196. Now press a letter. The selected text is deleted, and the single letter
  197. replaces it. You are in Insert mode now, thus you can continue typing.
  198. Since typing normal text causes the selected text to be deleted, you can not
  199. use the normal movement commands "hjkl", "w", etc. Instead, use the shifted
  200. function keys. <S-Left> (shifted cursor left key) moves the cursor left. The
  201. selected text is changed like in Visual mode. The other shifted cursor keys
  202. do what you expect. <S-End> and <S-Home> also work.
  203. You can tune the way Select mode works with the 'selectmode' option.
  204. ==============================================================================
  205. Next chapter: |usr_10.txt| Making big changes
  206. Copyright: see |manual-copyright| vim:tw=78:ts=8:noet:ft=help:norl: