annotate runtime/doc/usr_08.txt @ 2235:4ba83ae8d505 vim73

Do not write an undo file if there is nothing to undo.
author Bram Moolenaar <bram@vim.org>
date Sun, 30 May 2010 17:17:42 +0200
parents 7c8c7c95a865
children 733f0dc510c3 12b829477c60
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2154
7c8c7c95a865 First step in the Vim 7.3 branch. Changed version numbers.
Bram Moolenaar <bram@zimbu.org>
parents: 1702
diff changeset
1 *usr_08.txt* For Vim version 7.3a. Last change: 2006 Jul 18
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 Splitting windows
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 Display two different files above each other. Or view two locations in the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9 file at the same time. See the difference between two files by putting them
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
10 side by side. All this is possible with split windows.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
11
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
12 |08.1| Split a window
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
13 |08.2| Split a window on another file
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
14 |08.3| Window size
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
15 |08.4| Vertical splits
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
16 |08.5| Moving windows
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
17 |08.6| Commands for all windows
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
18 |08.7| Viewing differences with vimdiff
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
19 |08.8| Various
685
d7e33248b9c8 updated for version 7.0206
vimboss
parents: 236
diff changeset
20 |08.9| Tab pages
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
21
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
22 Next chapter: |usr_09.txt| Using the GUI
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
23 Previous chapter: |usr_07.txt| Editing more than one file
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
24 Table of contents: |usr_toc.txt|
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
25
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
26 ==============================================================================
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
27 *08.1* Split a window
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
28
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
29 The easiest way to open a new window is to use the following command: >
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
30
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
31 :split
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
32
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
33 This command splits the screen into two windows and leaves the cursor in the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
34 top one:
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 one.c */ |
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
38 |~ |
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
39 |~ |
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
40 |one.c=============================|
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
41 |/* file one.c */ |
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
42 |~ |
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
43 |one.c=============================|
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
44 | |
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
45 +----------------------------------+
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
46
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
47 What you see here is two windows on the same file. The line with "====" is
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
48 that status line. It displays information about the window above it. (In
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
49 practice the status line will be in reverse video.)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
50 The two windows allow you to view two parts of the same file. For example,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
51 you could make the top window show the variable declarations of a program, and
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
52 the bottom one the code that uses these variables.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
53
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
54 The CTRL-W w command can be used to jump between the windows. If you are in
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
55 the top window, CTRL-W w jumps to the window below it. If you are in the
236
4707450c2b33 updated for version 7.0066
vimboss
parents: 7
diff changeset
56 bottom window it will jump to the first window. (CTRL-W CTRL-W does the same
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
57 thing, in case you let go of the CTRL key a bit later.)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
58
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
59
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
60 CLOSE THE WINDOW
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
61
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
62 To close a window, use the command: >
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
63
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
64 :close
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
65
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
66 Actually, any command that quits editing a file works, like ":quit" and "ZZ".
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
67 But ":close" prevents you from accidentally exiting Vim when you close the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
68 last window.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
69
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
70
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
71 CLOSING ALL OTHER WINDOWS
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
72
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
73 If you have opened a whole bunch of windows, but now want to concentrate on
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
74 one of them, this command will be useful: >
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
75
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
76 :only
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
77
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
78 This closes all windows, except for the current one. If any of the other
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
79 windows has changes, you will get an error message and that window won't be
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
80 closed.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
81
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
82 ==============================================================================
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
83 *08.2* Split a window on another file
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
84
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
85 The following command opens a second window and starts editing the given file:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
86 >
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
87 :split two.c
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
88
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
89 If you were editing one.c, then the result looks like this:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
90
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
91 +----------------------------------+
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
92 |/* file two.c */ |
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
93 |~ |
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
94 |~ |
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
95 |two.c=============================|
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
96 |/* file one.c */ |
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
97 |~ |
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
98 |one.c=============================|
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
99 | |
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
100 +----------------------------------+
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
101
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
102 To open a window on a new, empty file, use this: >
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
103
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
104 :new
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
105
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
106 You can repeat the ":split" and ":new" commands to create as many windows as
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
107 you like.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
108
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
109 ==============================================================================
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
110 *08.3* Window size
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
111
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
112 The ":split" command can take a number argument. If specified, this will be
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
113 the height of the new window. For example, the following opens a new window
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
114 three lines high and starts editing the file alpha.c: >
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
115
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
116 :3split alpha.c
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
117
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
118 For existing windows you can change the size in several ways. When you have a
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
119 working mouse, it is easy: Move the mouse pointer to the status line that
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
120 separates two windows, and drag it up or down.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
121
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
122 To increase the size of a window: >
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
123
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
124 CTRL-W +
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
125
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
126 To decrease it: >
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
127
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
128 CTRL-W -
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
129
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
130 Both of these commands take a count and increase or decrease the window size
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
131 by that many lines. Thus "4 CTRL-W +" make the window four lines higher.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
132
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
133 To set the window height to a specified number of lines: >
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
134
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
135 {height}CTRL-W _
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
136
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
137 That's: a number {height}, CTRL-W and then an underscore (the - key with Shift
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
138 on English-US keyboards).
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
139 To make a window as high as it can be, use the CTRL-W _ command without a
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
140 count.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
141
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
142
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
143 USING THE MOUSE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
144
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
145 In Vim you can do many things very quickly from the keyboard. Unfortunately,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
146 the window resizing commands require quite a bit of typing. In this case,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
147 using the mouse is faster. Position the mouse pointer on a status line. Now
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
148 press the left mouse button and drag. The status line will move, thus making
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
149 the window on one side higher and the other smaller.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
150
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
151
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
152 OPTIONS
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
153
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
154 The 'winheight' option can be set to a minimal desired height of a window and
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
155 'winminheight' to a hard minimum height.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
156 Likewise, there is 'winwidth' for the minimal desired width and
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
157 'winminwidth' for the hard minimum width.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
158 The 'equalalways' option, when set, makes Vim equalize the windows sizes
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
159 when a window is closed or opened.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
160
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
161 ==============================================================================
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
162 *08.4* Vertical splits
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
163
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
164 The ":split" command creates the new window above the current one. To make
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
165 the window appear at the left side, use: >
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
166
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
167 :vsplit
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
168
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
169 or: >
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
170 :vsplit two.c
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
171
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
172 The result looks something like this:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
173
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
174 +--------------------------------------+
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
175 |/* file two.c */ |/* file one.c */ |
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
176 |~ |~ |
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
177 |~ |~ |
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
178 |~ |~ |
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
179 |two.c===============one.c=============|
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
180 | |
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
181 +--------------------------------------+
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
182
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
183 Actually, the | lines in the middle will be in reverse video. This is called
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
184 the vertical separator. It separates the two windows left and right of it.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
185
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
186 There is also the ":vnew" command, to open a vertically split window on a new,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
187 empty file. Another way to do this: >
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
188
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
189 :vertical new
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
190
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
191 The ":vertical" command can be inserted before another command that splits a
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
192 window. This will cause that command to split the window vertically instead
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
193 of horizontally. (If the command doesn't split a window, it works
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
194 unmodified.)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
195
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
196
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
197 MOVING BETWEEN WINDOWS
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
198
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
199 Since you can split windows horizontally and vertically as much as you like,
1121
e63691e7c504 updated for version 7.1a
vimboss
parents: 874
diff changeset
200 you can create almost any layout of windows. Then you can use these commands
e63691e7c504 updated for version 7.1a
vimboss
parents: 874
diff changeset
201 to move between them:
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
202
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
203 CTRL-W h move to the window on the left
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
204 CTRL-W j move to the window below
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
205 CTRL-W k move to the window above
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
206 CTRL-W l move to the window on the right
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
207
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
208 CTRL-W t move to the TOP window
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
209 CTRL-W b move to the BOTTOM window
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
210
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
211 You will notice the same letters as used for moving the cursor. And the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
212 cursor keys can also be used, if you like.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
213 More commands to move to other windows: |Q_wi|.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
214
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
215 ==============================================================================
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
216 *08.5* Moving windows
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
217
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
218 You have split a few windows, but now they are in the wrong place. Then you
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
219 need a command to move the window somewhere else. For example, you have three
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
220 windows like this:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
221
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
222 +----------------------------------+
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
223 |/* file two.c */ |
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
224 |~ |
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
225 |~ |
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
226 |two.c=============================|
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
227 |/* file three.c */ |
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
228 |~ |
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
229 |~ |
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
230 |three.c===========================|
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
231 |/* file one.c */ |
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
232 |~ |
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
233 |one.c=============================|
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
234 | |
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
235 +----------------------------------+
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
236
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
237 Clearly the last one should be at the top. Go to that window (using CTRL-W w)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
238 and the type this command: >
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
239
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
240 CTRL-W K
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
241
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
242 This uses the uppercase letter K. What happens is that the window is moved to
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
243 the very top. You will notice that K is again used for moving upwards.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
244 When you have vertical splits, CTRL-W K will move the current window to the
1121
e63691e7c504 updated for version 7.1a
vimboss
parents: 874
diff changeset
245 top and make it occupy the full width of the Vim window. If this is your
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
246 layout:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
247
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
248 +-------------------------------------------+
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
249 |/* two.c */ |/* three.c */ |/* one.c */ |
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
250 |~ |~ |~ |
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
251 |~ |~ |~ |
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
252 |~ |~ |~ |
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
253 |~ |~ |~ |
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
254 |~ |~ |~ |
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
255 |two.c=========three.c=========one.c========|
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
256 | |
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
257 +-------------------------------------------+
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
258
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
259 Then using CTRL-W K in the middle window (three.c) will result in:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
260
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
261 +-------------------------------------------+
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
262 |/* three.c */ |
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
263 |~ |
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
264 |~ |
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
265 |three.c====================================|
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
266 |/* two.c */ |/* one.c */ |
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
267 |~ |~ |
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
268 |two.c==================one.c===============|
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
269 | |
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
270 +-------------------------------------------+
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
271
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
272 The other three similar commands (you can probably guess these now):
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
273
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
274 CTRL-W H move window to the far left
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
275 CTRL-W J move window to the bottom
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
276 CTRL-W L move window to the far right
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
277
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
278 ==============================================================================
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
279 *08.6* Commands for all windows
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
280
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
281 When you have several windows open and you want to quit Vim, you can close
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
282 each window separately. A quicker way is using this command: >
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
283
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
284 :qall
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
285
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
286 This stands for "quit all". If any of the windows contain changes, Vim will
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
287 not exit. The cursor will automatically be positioned in a window with
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
288 changes. You can then either use ":write" to save the changes, or ":quit!" to
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
289 throw them away.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
290
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
291 If you know there are windows with changes, and you want to save all these
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
292 changes, use this command: >
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
293
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
294 :wall
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
295
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
296 This stands for "write all". But actually, it only writes files with
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
297 changes. Vim knows it doesn't make sense to write files that were not
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
298 changed.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
299 And then there is the combination of ":qall" and ":wall": the "write and
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
300 quit all" command: >
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
301
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
302 :wqall
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
303
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
304 This writes all modified files and quits Vim.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
305 Finally, there is a command that quits Vim and throws away all changes: >
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
306
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
307 :qall!
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
308
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
309 Be careful, there is no way to undo this command!
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
310
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
311
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
312 OPENING A WINDOW FOR ALL ARGUMENTS
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
313
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
314 To make Vim open a window for each file, start it with the "-o" argument: >
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
315
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
316 vim -o one.txt two.txt three.txt
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
317
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
318 This results in:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
319
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
320 +-------------------------------+
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
321 |file one.txt |
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
322 |~ |
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
323 |one.txt========================|
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
324 |file two.txt |
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
325 |~ |
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
326 |two.txt========================|
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
327 |file three.txt |
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
328 |~ |
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
329 |three.txt======================|
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
330 | |
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
331 +-------------------------------+
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
332
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
333 The "-O" argument is used to get vertically split windows.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
334 When Vim is already running, the ":all" command opens a window for each
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
335 file in the argument list. ":vertical all" does it with vertical splits.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
336
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
337 ==============================================================================
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
338 *08.7* Viewing differences with vimdiff
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
339
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
340 There is a special way to start Vim, which shows the differences between two
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
341 files. Let's take a file "main.c" and insert a few characters in one line.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
342 Write this file with the 'backup' option set, so that the backup file
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
343 "main.c~" will contain the previous version of the file.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
344 Type this command in a shell (not in Vim): >
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
345
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
346 vimdiff main.c~ main.c
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
347
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
348 Vim will start, with two windows side by side. You will only see the line
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
349 in which you added characters, and a few lines above and below it.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
350
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
351 VV VV
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
352 +-----------------------------------------+
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
353 |+ +--123 lines: /* a|+ +--123 lines: /* a| <- fold
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
354 | text | text |
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
355 | text | text |
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
356 | text | text |
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
357 | text | changed text | <- changed line
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
358 | text | text |
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
359 | text | ------------------| <- deleted line
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
360 | text | text |
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
361 | text | text |
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
362 | text | text |
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
363 |+ +--432 lines: text|+ +--432 lines: text| <- fold
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
364 | ~ | ~ |
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
365 | ~ | ~ |
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
366 |main.c~==============main.c==============|
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
367 | |
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
368 +-----------------------------------------+
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
369
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
370 (This picture doesn't show the highlighting, use the vimdiff command for a
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
371 better look.)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
372
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
373 The lines that were not modified have been collapsed into one line. This is
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
374 called a closed fold. They are indicated in the picture with "<- fold". Thus
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
375 the single fold line at the top stands for 123 text lines. These lines are
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
376 equal in both files.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
377 The line marked with "<- changed line" is highlighted, and the inserted
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
378 text is displayed with another color. This clearly shows what the difference
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
379 is between the two files.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
380 The line that was deleted is displayed with "---" in the main.c window.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
381 See the "<- deleted line" marker in the picture. These characters are not
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
382 really there. They just fill up main.c, so that it displays the same number
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
383 of lines as the other window.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
384
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
385
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
386 THE FOLD COLUMN
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
387
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
388 Each window has a column on the left with a slightly different background. In
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
389 the picture above these are indicated with "VV". You notice there is a plus
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
390 character there, in front of each closed fold. Move the mouse pointer to that
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
391 plus and click the left button. The fold will open, and you can see the text
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
392 that it contains.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
393 The fold column contains a minus sign for an open fold. If you click on
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
394 this -, the fold will close.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
395 Obviously, this only works when you have a working mouse. You can also use
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
396 "zo" to open a fold and "zc" to close it.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
397
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
398
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
399 DIFFING IN VIM
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
400
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
401 Another way to start in diff mode can be done from inside Vim. Edit the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
402 "main.c" file, then make a split and show the differences: >
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
403
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
404 :edit main.c
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
405 :vertical diffsplit main.c~
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
406
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
407 The ":vertical" command is used to make the window split vertically. If you
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
408 omit this, you will get a horizontal split.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
409
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
410 If you have a patch or diff file, you can use the third way to start diff
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
411 mode. First edit the file to which the patch applies. Then tell Vim the name
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
412 of the patch file: >
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
413
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
414 :edit main.c
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
415 :vertical diffpatch main.c.diff
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
416
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
417 WARNING: The patch file must contain only one patch, for the file you are
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
418 editing. Otherwise you will get a lot of error messages, and some files might
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
419 be patched unexpectedly.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
420 The patching will only be done to the copy of the file in Vim. The file on
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
421 your harddisk will remain unmodified (until you decide to write the file).
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
422
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
423
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
424 SCROLL BINDING
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
425
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
426 When the files have more changes, you can scroll in the usual way. Vim will
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
427 try to keep both the windows start at the same position, so you can easily see
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
428 the differences side by side.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
429 When you don't want this for a moment, use this command: >
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
430
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
431 :set noscrollbind
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
432
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
433
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
434 JUMPING TO CHANGES
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
435
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
436 When you have disabled folding in some way, it may be difficult to find the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
437 changes. Use this command to jump forward to the next change: >
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
438
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
439 ]c
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
440
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
441 To go the other way use: >
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
442
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
443 [c
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
444
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
445 Prepended a count to jump further away.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
446
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
447
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
448 REMOVING CHANGES
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
449
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
450 You can move text from one window to the other. This either removes
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
451 differences or adds new ones. Vim doesn't keep the highlighting updated in
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
452 all situations. To update it use this command: >
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
453
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
454 :diffupdate
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
455
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
456 To remove a difference, you can move the text in a highlighted block from one
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
457 window to another. Take the "main.c" and "main.c~" example above. Move the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
458 cursor to the left window, on the line that was deleted in the other window.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
459 Now type this command: >
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
460
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
461 dp
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
462
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
463 The change will be removed by putting the text of the current window in the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
464 other window. "dp" stands for "diff put".
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
465 You can also do it the other way around. Move the cursor to the right
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
466 window, to the line where "changed" was inserted. Now type this command: >
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
467
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
468 do
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
469
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
470 The change will now be removed by getting the text from the other window.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
471 Since there are no changes left now, Vim puts all text in a closed fold.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
472 "do" stands for "diff obtain". "dg" would have been better, but that already
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
473 has a different meaning ("dgg" deletes from the cursor until the first line).
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
474
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
475 For details about diff mode, see |vimdiff|.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
476
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
477 ==============================================================================
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
478 *08.8* Various
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
479
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
480 The 'laststatus' option can be used to specify when the last window has a
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
481 statusline:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
482
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
483 0 never
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
484 1 only when there are split windows (the default)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
485 2 always
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
486
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
487 Many commands that edit another file have a variant that splits the window.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
488 For Command-line commands this is done by prepending an "s". For example:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
489 ":tag" jumps to a tag, ":stag" splits the window and jumps to a
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
490 tag.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
491 For Normal mode commands a CTRL-W is prepended. CTRL-^ jumps to the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
492 alternate file, CTRL-W CTRL-^ splits the window and edits the alternate file.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
493
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
494 The 'splitbelow' option can be set to make a new window appear below the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
495 current window. The 'splitright' option can be set to make a vertically split
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
496 window appear right of the current window.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
497
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
498 When splitting a window you can prepend a modifier command to tell where the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
499 window is to appear:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
500
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
501 :leftabove {cmd} left or above the current window
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
502 :aboveleft {cmd} idem
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
503 :rightbelow {cmd} right or below the current window
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
504 :belowright {cmd} idem
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
505 :topleft {cmd} at the top or left of the Vim window
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
506 :botright {cmd} at the bottom or right of the Vim window
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
507
685
d7e33248b9c8 updated for version 7.0206
vimboss
parents: 236
diff changeset
508
d7e33248b9c8 updated for version 7.0206
vimboss
parents: 236
diff changeset
509 ==============================================================================
d7e33248b9c8 updated for version 7.0206
vimboss
parents: 236
diff changeset
510 *08.9* Tab pages
d7e33248b9c8 updated for version 7.0206
vimboss
parents: 236
diff changeset
511
d7e33248b9c8 updated for version 7.0206
vimboss
parents: 236
diff changeset
512 You will have noticed that windows never overlap. That means you quickly run
d7e33248b9c8 updated for version 7.0206
vimboss
parents: 236
diff changeset
513 out of screen space. The solution for this is called Tab pages.
d7e33248b9c8 updated for version 7.0206
vimboss
parents: 236
diff changeset
514
d7e33248b9c8 updated for version 7.0206
vimboss
parents: 236
diff changeset
515 Assume you are editing "thisfile". To create a new tab page use this command: >
d7e33248b9c8 updated for version 7.0206
vimboss
parents: 236
diff changeset
516
d7e33248b9c8 updated for version 7.0206
vimboss
parents: 236
diff changeset
517 :tabedit thatfile
d7e33248b9c8 updated for version 7.0206
vimboss
parents: 236
diff changeset
518
d7e33248b9c8 updated for version 7.0206
vimboss
parents: 236
diff changeset
519 This will edit the file "thatfile" in a window that occupies the whole Vim
d7e33248b9c8 updated for version 7.0206
vimboss
parents: 236
diff changeset
520 window. And you will notice a bar at the top with the two file names:
d7e33248b9c8 updated for version 7.0206
vimboss
parents: 236
diff changeset
521
d7e33248b9c8 updated for version 7.0206
vimboss
parents: 236
diff changeset
522 +----------------------------------+
687
d4b8e06e7c96 updated for version 7.0207
vimboss
parents: 685
diff changeset
523 | thisfile | /thatfile/ __________X| (thatfile is bold)
856
8cd729851562 updated for version 7.0g
vimboss
parents: 842
diff changeset
524 |/* thatfile */ |
685
d7e33248b9c8 updated for version 7.0206
vimboss
parents: 236
diff changeset
525 |that |
d7e33248b9c8 updated for version 7.0206
vimboss
parents: 236
diff changeset
526 |that |
856
8cd729851562 updated for version 7.0g
vimboss
parents: 842
diff changeset
527 |~ |
8cd729851562 updated for version 7.0g
vimboss
parents: 842
diff changeset
528 |~ |
8cd729851562 updated for version 7.0g
vimboss
parents: 842
diff changeset
529 |~ |
685
d7e33248b9c8 updated for version 7.0206
vimboss
parents: 236
diff changeset
530 | |
d7e33248b9c8 updated for version 7.0206
vimboss
parents: 236
diff changeset
531 +----------------------------------+
d7e33248b9c8 updated for version 7.0206
vimboss
parents: 236
diff changeset
532
d7e33248b9c8 updated for version 7.0206
vimboss
parents: 236
diff changeset
533 You now have two tab pages. The first one has a window for "thisfile" and the
d7e33248b9c8 updated for version 7.0206
vimboss
parents: 236
diff changeset
534 second one a window for "thatfile". It's like two pages that are on top of
d7e33248b9c8 updated for version 7.0206
vimboss
parents: 236
diff changeset
535 eachother, with a tab sticking out of each page showing the file name.
d7e33248b9c8 updated for version 7.0206
vimboss
parents: 236
diff changeset
536
d7e33248b9c8 updated for version 7.0206
vimboss
parents: 236
diff changeset
537 Now use the mouse to click on "thisfile" in the top line. The result is
d7e33248b9c8 updated for version 7.0206
vimboss
parents: 236
diff changeset
538
d7e33248b9c8 updated for version 7.0206
vimboss
parents: 236
diff changeset
539 +----------------------------------+
687
d4b8e06e7c96 updated for version 7.0207
vimboss
parents: 685
diff changeset
540 | /thisfile/ | thatfile __________X| (thisfile is bold)
856
8cd729851562 updated for version 7.0g
vimboss
parents: 842
diff changeset
541 |/* thisfile */ |
685
d7e33248b9c8 updated for version 7.0206
vimboss
parents: 236
diff changeset
542 |this |
d7e33248b9c8 updated for version 7.0206
vimboss
parents: 236
diff changeset
543 |this |
856
8cd729851562 updated for version 7.0g
vimboss
parents: 842
diff changeset
544 |~ |
8cd729851562 updated for version 7.0g
vimboss
parents: 842
diff changeset
545 |~ |
8cd729851562 updated for version 7.0g
vimboss
parents: 842
diff changeset
546 |~ |
685
d7e33248b9c8 updated for version 7.0206
vimboss
parents: 236
diff changeset
547 | |
d7e33248b9c8 updated for version 7.0206
vimboss
parents: 236
diff changeset
548 +----------------------------------+
d7e33248b9c8 updated for version 7.0206
vimboss
parents: 236
diff changeset
549
d7e33248b9c8 updated for version 7.0206
vimboss
parents: 236
diff changeset
550 Thus you can switch between tab pages by clicking on the label in the top
d7e33248b9c8 updated for version 7.0206
vimboss
parents: 236
diff changeset
551 line. If you don't have a mouse or don't want to use it, you can use the "gt"
d7e33248b9c8 updated for version 7.0206
vimboss
parents: 236
diff changeset
552 command. Mnemonic: Goto Tab.
d7e33248b9c8 updated for version 7.0206
vimboss
parents: 236
diff changeset
553
d7e33248b9c8 updated for version 7.0206
vimboss
parents: 236
diff changeset
554 Now let's create another tab page with the command: >
d7e33248b9c8 updated for version 7.0206
vimboss
parents: 236
diff changeset
555
d7e33248b9c8 updated for version 7.0206
vimboss
parents: 236
diff changeset
556 :tab split
d7e33248b9c8 updated for version 7.0206
vimboss
parents: 236
diff changeset
557
d7e33248b9c8 updated for version 7.0206
vimboss
parents: 236
diff changeset
558 This makes a new tab page with one window that is editing the same buffer as
d7e33248b9c8 updated for version 7.0206
vimboss
parents: 236
diff changeset
559 the window we were in:
d7e33248b9c8 updated for version 7.0206
vimboss
parents: 236
diff changeset
560
d7e33248b9c8 updated for version 7.0206
vimboss
parents: 236
diff changeset
561 +-------------------------------------+
687
d4b8e06e7c96 updated for version 7.0207
vimboss
parents: 685
diff changeset
562 | thisfile | /thisfile/ | thatfile __X| (thisfile is bold)
856
8cd729851562 updated for version 7.0g
vimboss
parents: 842
diff changeset
563 |/* thisfile */ |
685
d7e33248b9c8 updated for version 7.0206
vimboss
parents: 236
diff changeset
564 |this |
d7e33248b9c8 updated for version 7.0206
vimboss
parents: 236
diff changeset
565 |this |
856
8cd729851562 updated for version 7.0g
vimboss
parents: 842
diff changeset
566 |~ |
8cd729851562 updated for version 7.0g
vimboss
parents: 842
diff changeset
567 |~ |
8cd729851562 updated for version 7.0g
vimboss
parents: 842
diff changeset
568 |~ |
685
d7e33248b9c8 updated for version 7.0206
vimboss
parents: 236
diff changeset
569 | |
d7e33248b9c8 updated for version 7.0206
vimboss
parents: 236
diff changeset
570 +-------------------------------------+
d7e33248b9c8 updated for version 7.0206
vimboss
parents: 236
diff changeset
571
d7e33248b9c8 updated for version 7.0206
vimboss
parents: 236
diff changeset
572 You can put ":tab" before any Ex command that opens a window. The window will
d7e33248b9c8 updated for version 7.0206
vimboss
parents: 236
diff changeset
573 be opened in a new tab page. Another example: >
d7e33248b9c8 updated for version 7.0206
vimboss
parents: 236
diff changeset
574
d7e33248b9c8 updated for version 7.0206
vimboss
parents: 236
diff changeset
575 :tab help gt
d7e33248b9c8 updated for version 7.0206
vimboss
parents: 236
diff changeset
576
d7e33248b9c8 updated for version 7.0206
vimboss
parents: 236
diff changeset
577 Will show the help text for "gt" in a new tab page.
d7e33248b9c8 updated for version 7.0206
vimboss
parents: 236
diff changeset
578
d7e33248b9c8 updated for version 7.0206
vimboss
parents: 236
diff changeset
579 A few more things you can do with tab pages:
d7e33248b9c8 updated for version 7.0206
vimboss
parents: 236
diff changeset
580
d7e33248b9c8 updated for version 7.0206
vimboss
parents: 236
diff changeset
581 - click with the mouse in the space after the last label
856
8cd729851562 updated for version 7.0g
vimboss
parents: 842
diff changeset
582 The next tab page will be selected, like with "gt".
685
d7e33248b9c8 updated for version 7.0206
vimboss
parents: 236
diff changeset
583
d7e33248b9c8 updated for version 7.0206
vimboss
parents: 236
diff changeset
584 - click with the mouse on the "X" in the top right corner
856
8cd729851562 updated for version 7.0g
vimboss
parents: 842
diff changeset
585 The current tab page will be closed. Unless there are unsaved
685
d7e33248b9c8 updated for version 7.0206
vimboss
parents: 236
diff changeset
586 changes in the current tab page.
d7e33248b9c8 updated for version 7.0206
vimboss
parents: 236
diff changeset
587
d7e33248b9c8 updated for version 7.0206
vimboss
parents: 236
diff changeset
588 - double click with the mouse in the top line
856
8cd729851562 updated for version 7.0g
vimboss
parents: 842
diff changeset
589 A new tab page will be created.
685
d7e33248b9c8 updated for version 7.0206
vimboss
parents: 236
diff changeset
590
d7e33248b9c8 updated for version 7.0206
vimboss
parents: 236
diff changeset
591 - the "tabonly" command
856
8cd729851562 updated for version 7.0g
vimboss
parents: 842
diff changeset
592 Closes all tab pages except the current one. Unless there are unsaved
685
d7e33248b9c8 updated for version 7.0206
vimboss
parents: 236
diff changeset
593 changes in other tab pages.
d7e33248b9c8 updated for version 7.0206
vimboss
parents: 236
diff changeset
594
d7e33248b9c8 updated for version 7.0206
vimboss
parents: 236
diff changeset
595 For more information about tab pages see |tab-page|.
d7e33248b9c8 updated for version 7.0206
vimboss
parents: 236
diff changeset
596
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
597 ==============================================================================
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
598
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
599 Next chapter: |usr_09.txt| Using the GUI
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
600
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
601 Copyright: see |manual-copyright| vim:tw=78:ts=8:ft=help:norl: