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