annotate runtime/doc/usr_09.txt @ 7692:2252cd6501d3

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