| 1 |
|
| 2 |
|
| 3 |
. |
| 4 |
###x. .| |
| 5 |
d#####x, ,v|| |
| 6 |
'+#####v|||||| |
| 7 |
,v|||||+'. _ _ _ |
| 8 |
,v|||||^'>#### | | | | ___ | | (_) __ __ |
| 9 |
|||||^' .v#### | |___| | / \ | | _ \ \/ / |
| 10 |
||||=..v#####P' | ___ | / ^ | | | | | \ / |
| 11 |
''v'>#####P' | | | | | --- | | | | / \ |
| 12 |
,######/P||x. |_| |_| \___/ |_| |_| /_/\_\ |
| 13 |
####P' "x|||||, |
| 14 |
|/' 'x||| A post-modern modal text editor. |
| 15 |
' '| |
| 16 |
|
| 17 |
|
| 18 |
Welcome to the Helix tutorial! |
| 19 |
Press the j key until you reach the introduction. |
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
================================================================= |
| 24 |
= INTRODUCTION = |
| 25 |
================================================================= |
| 26 |
|
| 27 |
Welcome to the Helix editor! Helix is different from editors |
| 28 |
you might be used to in that it is modal, meaning that it has |
| 29 |
different modes for editing text. The primary modes you will |
| 30 |
use are Normal mode and Insert mode. While in Normal mode, the |
| 31 |
keys you type won't actually type text. Instead, they will |
| 32 |
perform various actions with the text. This allows for more |
| 33 |
efficient editing. This tutor will teach you how you can make |
| 34 |
use of Helix's modal editing features. To begin, ensure your |
| 35 |
CapsLock key is not pressed and hold the j key until you reach |
| 36 |
the first lesson. |
| 37 |
|
| 38 |
This tutor opens in an unnamed buffer. |
| 39 |
* To quit without saving changes, use :q!. |
| 40 |
* To save your changes to a file, use :w <path> and then :q. |
| 41 |
|
| 42 |
|
| 43 |
|
| 44 |
|
| 45 |
|
| 46 |
|
| 47 |
|
| 48 |
|
| 49 |
================================================================= |
| 50 |
= 1.1 BASIC CURSOR MOVEMENT = |
| 51 |
================================================================= |
| 52 |
|
| 53 |
↑ |
| 54 |
k * h is on the left |
| 55 |
← h l → * l is on the right |
| 56 |
j * j looks like a down arrow |
| 57 |
↓ |
| 58 |
|
| 59 |
The cursor can be moved using the h, j, k, l keys, as shown |
| 60 |
above. The cursor / arrow keys will also work, but it is faster |
| 61 |
to use the hjkl keys as they are closer to the other keys you |
| 62 |
will be using. Try moving around to get a feel for hjkl. |
| 63 |
Once you're ready, hold j to continue to the next lesson. |
| 64 |
|
| 65 |
|
| 66 |
|
| 67 |
|
| 68 |
|
| 69 |
|
| 70 |
|
| 71 |
================================================================= |
| 72 |
= 1.2 EXITING HELIX = |
| 73 |
================================================================= |
| 74 |
|
| 75 |
1. Type : to enter Command mode. Your cursor will |
| 76 |
move to the bottom of the screen. |
| 77 |
2. Type q or quit and press Enter to exit Helix. |
| 78 |
|
| 79 |
Note: The quit command will fail if there are unsaved changes. |
| 80 |
To force quit and DISCARD these changes, type q! or quit!. |
| 81 |
You will learn how to save files later. |
| 82 |
|
| 83 |
To exit Command mode without entering a command, press Escape. |
| 84 |
|
| 85 |
Now, move on to the next lesson. |
| 86 |
|
| 87 |
|
| 88 |
|
| 89 |
|
| 90 |
|
| 91 |
|
| 92 |
|
| 93 |
================================================================= |
| 94 |
= 1.3 DELETION = |
| 95 |
================================================================= |
| 96 |
|
| 97 |
Type the d key to delete the character under the cursor. |
| 98 |
|
| 99 |
1. Move the cursor to the line marked '-->' below. |
| 100 |
2. Move the cursor to each extra character, and type d to |
| 101 |
delete it. |
| 102 |
|
| 103 |
--> Thhiss senttencee haass exxtra charracterss. |
| 104 |
This sentence has extra characters. |
| 105 |
|
| 106 |
Once the sentence is correct, move on to the next lesson. |
| 107 |
|
| 108 |
|
| 109 |
|
| 110 |
|
| 111 |
|
| 112 |
|
| 113 |
|
| 114 |
|
| 115 |
================================================================= |
| 116 |
= 1.4 INSERT MODE = |
| 117 |
================================================================= |
| 118 |
|
| 119 |
Type the i key to enter Insert mode. |
| 120 |
|
| 121 |
1. Move the cursor to the line marked '-->' below. |
| 122 |
2. Move to a place in the line which is missing text and type |
| 123 |
i to enter Insert mode. Keys you type will now type text. |
| 124 |
3. Enter the missing text. |
| 125 |
4. Press Escape to exit Insert mode and return to Normal mode. |
| 126 |
5. Repeat until the line matches the line below it. |
| 127 |
|
| 128 |
--> Th stce misg so. |
| 129 |
This sentence is missing some text. |
| 130 |
|
| 131 |
Note: The status bar will display your current mode. |
| 132 |
Notice that when you type i, 'NOR' changes to 'INS'. |
| 133 |
|
| 134 |
|
| 135 |
|
| 136 |
|
| 137 |
================================================================= |
| 138 |
= 1.5 SAVING A FILE = |
| 139 |
================================================================= |
| 140 |
|
| 141 |
Type :w / :write to save a file. |
| 142 |
|
| 143 |
1. Exit Helix using :q! as explained before, or open a new |
| 144 |
terminal. |
| 145 |
2. Open a file in Helix by running: hx FILENAME |
| 146 |
3. Make some edits to the file. |
| 147 |
4. Type : to enter Command mode. |
| 148 |
5. Type w or write, and press Enter to save the file. |
| 149 |
|
| 150 |
You can also type wq or write-quit to save and exit. |
| 151 |
|
| 152 |
Note: You can optionally enter a file path after the w / write |
| 153 |
command in order to save to that path. |
| 154 |
Note: If there are any unsaved changes to a file, a plus [+] |
| 155 |
will appear next to the file name in the status bar. |
| 156 |
|
| 157 |
|
| 158 |
|
| 159 |
================================================================= |
| 160 |
= CHAPTER 1 RECAP = |
| 161 |
================================================================= |
| 162 |
|
| 163 |
* Use the h,j,k,l keys to move the cursor. |
| 164 |
|
| 165 |
* Type : to enter Command mode. |
| 166 |
* The q / quit and q! / quit! commands will exit Helix. The |
| 167 |
former fails when there are unsaved changes. The latter |
| 168 |
discards them. |
| 169 |
* The w / write command will save the file. |
| 170 |
* The wq / write-quit command will do both. |
| 171 |
|
| 172 |
* Type d to delete the character at the cursor. |
| 173 |
|
| 174 |
* Type i to enter Insert mode and type text. Press Escape to |
| 175 |
return to Normal mode. |
| 176 |
|
| 177 |
|
| 178 |
|
| 179 |
|
| 180 |
|
| 181 |
================================================================= |
| 182 |
= 2.1 MORE INSERT COMMANDS = |
| 183 |
================================================================= |
| 184 |
|
| 185 |
As you saw, you can type i to enter Insert mode at the current |
| 186 |
position of the cursor. There are a few other ways you can |
| 187 |
enter Insert mode at different locations. |
| 188 |
|
| 189 |
Common examples of insertion commands include: |
| 190 |
i - Insert before the selection. |
| 191 |
a - Insert after the selection. (a means 'append') |
| 192 |
I - Insert at the start of the line. |
| 193 |
A - Insert at the end of the line. |
| 194 |
|
| 195 |
1. Move to anywhere in the line marked '-->' below. |
| 196 |
2. Type A (Shift-a), your cursor will move to the end of |
| 197 |
the line and you will be able to type. |
| 198 |
3. Type the text necessary to match the line below. |
| 199 |
|
| 200 |
--> This sentence is miss |
| 201 |
This sentence is missing some text. |
| 202 |
|
| 203 |
================================================================= |
| 204 |
= 2.2 OPENING LINES = |
| 205 |
================================================================= |
| 206 |
|
| 207 |
Type o to add a newline and insert below the cursor. |
| 208 |
Type O to add a newline and insert above the cursor. |
| 209 |
|
| 210 |
1. Move the cursor to the line marked '-->' below. |
| 211 |
2. Type o to open a line below and type your answer. |
| 212 |
|
| 213 |
--> What is the best editor? |
| 214 |
|
| 215 |
|
| 216 |
|
| 217 |
|
| 218 |
|
| 219 |
|
| 220 |
|
| 221 |
|
| 222 |
|
| 223 |
|
| 224 |
|
| 225 |
================================================================= |
| 226 |
= CHAPTER 2 RECAP = |
| 227 |
================================================================= |
| 228 |
|
| 229 |
* Type a to append to the selection. |
| 230 |
|
| 231 |
* Type I to enter Insert mode at the first non-whitespace |
| 232 |
character at the start of a line. |
| 233 |
|
| 234 |
* Type A to enter Insert mode at the end of a line. |
| 235 |
|
| 236 |
* Use o and O to open lines below and above the cursor respectively. |
| 237 |
|
| 238 |
|
| 239 |
|
| 240 |
|
| 241 |
|
| 242 |
|
| 243 |
|
| 244 |
|
| 245 |
|
| 246 |
|
| 247 |
================================================================= |
| 248 |
= 3.1 MOTIONS AND SELECTIONS = |
| 249 |
================================================================= |
| 250 |
|
| 251 |
Type w to select forward until the next word. |
| 252 |
|
| 253 |
The d key doesn't actually delete the character at the cursor, |
| 254 |
it deletes all selected text. Your cursor is like a |
| 255 |
single-character selection. |
| 256 |
|
| 257 |
1. Move the cursor to the line marked '-->' below. |
| 258 |
2. Move to the beginning of a word that needs to be deleted. |
| 259 |
3. Type w to select until the beginning of the next word. |
| 260 |
4. Type d to delete the selection. |
| 261 |
5. Repeat for all extra words in the line. |
| 262 |
|
| 263 |
--> This sentence pencil has vacuum extra words in the it. |
| 264 |
This sentence has extra words in it. |
| 265 |
|
| 266 |
|
| 267 |
|
| 268 |
|
| 269 |
================================================================= |
| 270 |
= 3.2 MORE MOTIONS = |
| 271 |
================================================================= |
| 272 |
|
| 273 |
As you saw, typing w moves the cursor forward until the start |
| 274 |
of the next word, selecting the text traversed. This is useful |
| 275 |
for moving around text and for selecting text to operate on. |
| 276 |
|
| 277 |
Some common motions include: |
| 278 |
w - Move forward to before the beginning of the next word. |
| 279 |
e - Move forward to the end of the current word. |
| 280 |
b - Move backward to the beginning of the current word. |
| 281 |
|
| 282 |
To select the word under cursor, combine e and b. |
| 283 |
|
| 284 |
1. Move the cursor to the line marked '-->' below. |
| 285 |
2. Move to a 'd' letter. |
| 286 |
3. Type e to select a half of the word. |
| 287 |
4. Type b to select the rest. |
| 288 |
|
| 289 |
--> The Middle Kingdom. |
| 290 |
|
| 291 |
================================================================= |
| 292 |
= 3.3 WORDS AND words = |
| 293 |
================================================================= |
| 294 |
|
| 295 |
The w,e,b motions also have counterparts - W,E,B - which |
| 296 |
traverse WORDS instead of words. WORDS are only separated by |
| 297 |
whitespace, whereas words can be separated by other characters |
| 298 |
in addition to whitespace. |
| 299 |
|
| 300 |
1. Move the cursor to the beginning of the line marked with '-->'. |
| 301 |
2. Type w repeatedly to select individual words until you |
| 302 |
reach the end of the line. |
| 303 |
3. Note that 'one-of-a-kind' required 7 keystrokes to be |
| 304 |
traversed. '"modal"' required 3 keystrokes. |
| 305 |
4. Move the cursor back to beginning of the line marked '-->'. |
| 306 |
5. Type W repeatedly to select individual WORDS. |
| 307 |
6. Note that 'one-of-a-kind' and '"modal"' have been selected |
| 308 |
both with one keystroke each. |
| 309 |
|
| 310 |
--> Helix is a one-of-a-kind "modal" text editor |
| 311 |
|
| 312 |
|
| 313 |
================================================================= |
| 314 |
= 3.4 THE CHANGE COMMAND = |
| 315 |
================================================================= |
| 316 |
|
| 317 |
Type c to change the current selection. |
| 318 |
|
| 319 |
The change command deletes the current selection and enters |
| 320 |
Insert mode, so it is a very common shorthand for di. |
| 321 |
|
| 322 |
1. Move the cursor to the line marked '-->' below. |
| 323 |
2. Move to the start of an incorrect word and type e to |
| 324 |
select it. |
| 325 |
3. Type c to delete the word and enter Insert mode. |
| 326 |
4. Type the correct word. |
| 327 |
5. Repeat until the line matches the line below it. |
| 328 |
|
| 329 |
--> This paper has heavy words behind it. |
| 330 |
This sentence has incorrect words in it. |
| 331 |
|
| 332 |
|
| 333 |
|
| 334 |
|
| 335 |
================================================================= |
| 336 |
= 3.5 COUNTS WITH MOTIONS = |
| 337 |
================================================================= |
| 338 |
|
| 339 |
Type a number before a motion to repeat it that many times. |
| 340 |
|
| 341 |
1. Move the cursor to the line marked '-->' below. |
| 342 |
2. Type 2w to move 2 words forward. |
| 343 |
3. Type 3e to move to the end of the third word forward. |
| 344 |
4. Type 2b to move 2 words backwards. |
| 345 |
5. Try the above with different numbers. |
| 346 |
|
| 347 |
--> This is just a line with words you can move around in. |
| 348 |
|
| 349 |
|
| 350 |
|
| 351 |
|
| 352 |
|
| 353 |
|
| 354 |
|
| 355 |
|
| 356 |
|
| 357 |
================================================================= |
| 358 |
= 3.6 SELECT / EXTEND MODE = |
| 359 |
================================================================= |
| 360 |
|
| 361 |
Type v to enter Select mode. |
| 362 |
Type v again or Escape to return to Normal mode |
| 363 |
In Select mode every movement will extend the selection, as |
| 364 |
opposed to replacing it. |
| 365 |
|
| 366 |
1. Move the cursor to the line marked '-->' below. |
| 367 |
2. Move to the F of FOO and type v2w to select the two words. |
| 368 |
3. Type d to remove the two words. Notice d returns you to |
| 369 |
Normal mode. |
| 370 |
4. Move to the B of BAZ and repeat the sequence to delete them. |
| 371 |
|
| 372 |
--> Remove the FOO BAR distracting words BAZ BIZ from this line. |
| 373 |
|
| 374 |
|
| 375 |
|
| 376 |
|
| 377 |
|
| 378 |
|
| 379 |
================================================================= |
| 380 |
= 3.7 SELECTING LINES = |
| 381 |
================================================================= |
| 382 |
|
| 383 |
Type x to select a whole line. Type x again to select the next. |
| 384 |
|
| 385 |
1. Move the cursor to the second line marked '-->' below. |
| 386 |
2. Type x to select the line, and d to delete it. |
| 387 |
3. Move to the fourth line. |
| 388 |
4. Type x twice or type 2x to select 2 lines, and d to delete. |
| 389 |
|
| 390 |
--> 1) Roses are red, |
| 391 |
--> 2) Mud is fun, |
| 392 |
--> 3) Violets are blue, |
| 393 |
--> 4) I have a car, |
| 394 |
--> 5) Clocks tell time, |
| 395 |
--> 6) Sugar is sweet, |
| 396 |
--> 7) And so are you. |
| 397 |
|
| 398 |
Note: X works similarly to x although it doesn't extend to |
| 399 |
subsequent lines. X on an empty line does nothing. |
| 400 |
|
| 401 |
================================================================= |
| 402 |
= 3.8 COLLAPSING SELECTIONS = |
| 403 |
================================================================= |
| 404 |
|
| 405 |
Type ; to collapse selections to single cursors. |
| 406 |
|
| 407 |
Sometimes, you want to deselect without having to move the |
| 408 |
cursor(s). This can be done using the ; key. |
| 409 |
|
| 410 |
1. Move the cursor to the line marked '-->' below. |
| 411 |
2. Use the motions you have learned to move around the line, |
| 412 |
and try using ; to deselect the text after it is selected |
| 413 |
by the motions. |
| 414 |
|
| 415 |
--> This is an error-free line with words to move around in. |
| 416 |
|
| 417 |
Note: This works the same in Select mode. |
| 418 |
Note: Another related command is Alt-; which flips the direction |
| 419 |
of the selection (flips the selection's cursor and anchor). |
| 420 |
|
| 421 |
|
| 422 |
|
| 423 |
================================================================= |
| 424 |
= CHAPTER 3 RECAP = |
| 425 |
================================================================= |
| 426 |
|
| 427 |
* Type w to select forward until the next word. |
| 428 |
* Type e to select to the end of the current word. |
| 429 |
* Type b to select backward to the start of the current word. |
| 430 |
* Use uppercase counterparts, W,E,B, to traverse WORDS. |
| 431 |
|
| 432 |
* Type d to delete the entire selection. |
| 433 |
* Type c to delete the selection and enter Insert mode. |
| 434 |
|
| 435 |
* Type a number before a motion to repeat it that many times. |
| 436 |
|
| 437 |
* Type v to enter Select mode, where all motions extend the |
| 438 |
selection. |
| 439 |
|
| 440 |
* Type x to select the entire current line. Type x again to |
| 441 |
select the next line. |
| 442 |
|
| 443 |
* Type semicolon ( ; ) to collapse selection. |
| 444 |
|
| 445 |
================================================================= |
| 446 |
= 4.1 UNDOING = |
| 447 |
================================================================= |
| 448 |
|
| 449 |
Type u to undo. Type U to redo. |
| 450 |
|
| 451 |
1. Move the cursor to the line marked '-->' below. |
| 452 |
2. Move to the first error, and type d to delete it. |
| 453 |
3. Type u to undo your deletion. |
| 454 |
4. Fix all the errors on the line. |
| 455 |
5. Type u several times to undo your fixes. |
| 456 |
6. Type U (Shift-u) several times to redo your fixes. |
| 457 |
|
| 458 |
--> Fiix the errors on thhis line and reeplace them witth undo. |
| 459 |
|
| 460 |
|
| 461 |
|
| 462 |
|
| 463 |
|
| 464 |
|
| 465 |
|
| 466 |
|
| 467 |
================================================================= |
| 468 |
= 4.2 COPYING AND PASTING TEXT = |
| 469 |
================================================================= |
| 470 |
|
| 471 |
Type y to yank (copy) the selection. |
| 472 |
Type p to paste the yanked selection after the cursor. |
| 473 |
Type P to paste the yanked text before the cursor. |
| 474 |
|
| 475 |
1. Move the cursor to the line marked '-->' below. |
| 476 |
Make sure your cursor is on the "b" of banana. |
| 477 |
2. Type w to select "banana" and y to yank it. |
| 478 |
3. Move to the space between "2" and "3" and type p to paste. |
| 479 |
4. Repeat between "3" and "4". |
| 480 |
|
| 481 |
--> 1 banana 2 3 4 |
| 482 |
1 banana 2 banana 3 banana 4 |
| 483 |
|
| 484 |
Note: Whenever you delete or change text, Helix will copy the |
| 485 |
altered text. Use Alt-d / Alt-c instead to avoid this. |
| 486 |
Note: Helix doesn't share the system clipboard by default. Type |
| 487 |
Space + y / p to yank / paste on the system's clipboard. |
| 488 |
|
| 489 |
================================================================= |
| 490 |
= 4.3 SEARCHING IN FILE = |
| 491 |
================================================================= |
| 492 |
|
| 493 |
Type / to search forward in file, Enter to confirm search. |
| 494 |
Type n to go to the next search match. |
| 495 |
Type N to go to the previous search match. |
| 496 |
|
| 497 |
1. Type / and type in a common word, like 'banana'. |
| 498 |
2. Press Enter to confirm the search. |
| 499 |
3. Use n and N to cycle through the matches. |
| 500 |
|
| 501 |
Searching uses regular expressions, allowing you to target more |
| 502 |
complex expressions, which you'll learn about in the lesson on |
| 503 |
the select command. |
| 504 |
|
| 505 |
Note: To search backwards, type ? (Shift-/). |
| 506 |
Note: Unlike Vim, ? doesn't change the search direction. |
| 507 |
N always goes backwards and n always goes forwards. |
| 508 |
|
| 509 |
|
| 510 |
|
| 511 |
================================================================= |
| 512 |
= CHAPTER 4 RECAP = |
| 513 |
================================================================= |
| 514 |
|
| 515 |
* Type u to undo. Type U to redo. |
| 516 |
|
| 517 |
* Type y to yank (copy) text and p to paste. |
| 518 |
* Use Space + y and Space + p to yank / paste on the system |
| 519 |
clipboard. |
| 520 |
|
| 521 |
* Type / to search forward in file, and ? to search backwards. |
| 522 |
* Use n and N to cycle through search matches. |
| 523 |
|
| 524 |
|
| 525 |
|
| 526 |
|
| 527 |
|
| 528 |
|
| 529 |
|
| 530 |
|
| 531 |
|
| 532 |
|
| 533 |
================================================================= |
| 534 |
= 5.1 MULTIPLE CURSORS = |
| 535 |
================================================================= |
| 536 |
|
| 537 |
Type C to duplicate the cursor to the next suitable line. |
| 538 |
|
| 539 |
1. Move the cursor to the first line marked '-->' below. Place |
| 540 |
the cursor somewhere past the '-->'. |
| 541 |
2. Type C to duplicate the cursor to the next suitable line. |
| 542 |
Notice how it skips the line in the middle. Keys you type |
| 543 |
will now affect both cursors. |
| 544 |
3. Use Insert mode to correct the lines. The two cursors will |
| 545 |
fix both lines simultaneously. |
| 546 |
4. Type , to remove the first cursor. |
| 547 |
|
| 548 |
--> Fix th two nes at same ime. |
| 549 |
--> |
| 550 |
--> Fix th two nes at same ime. |
| 551 |
Fix these two lines at the same time. |
| 552 |
|
| 553 |
Note: Press Alt-C to do the same above the cursor. |
| 554 |
|
| 555 |
================================================================= |
| 556 |
= 5.2 THE SELECT COMMAND = |
| 557 |
================================================================= |
| 558 |
|
| 559 |
Type s to select matches in the selection. |
| 560 |
|
| 561 |
1. Move the cursor to the line marked '-->' below. |
| 562 |
2. Type x to select the line. |
| 563 |
3. Type s. A prompt will appear. |
| 564 |
4. Type 'apples' and press Enter. Both occurrences of |
| 565 |
'apples' in the line will be selected. |
| 566 |
5. You can now type c and change 'apples' to something else, |
| 567 |
like 'oranges'. |
| 568 |
6. Press Escape to exit Insert mode. |
| 569 |
7. Type , to remove the second cursor. |
| 570 |
|
| 571 |
--> I like to eat apples since my favorite fruit is apples. |
| 572 |
I like to eat oranges since my favorite fruit is oranges. |
| 573 |
|
| 574 |
|
| 575 |
|
| 576 |
|
| 577 |
================================================================= |
| 578 |
= 5.3 SELECTING VIA REGEX = |
| 579 |
================================================================= |
| 580 |
|
| 581 |
Like searching, the select command selects regular expressions, |
| 582 |
not just exact matches. |
| 583 |
|
| 584 |
1. Move the cursor to the line marked '-->' below. |
| 585 |
2. Select the line with x and then type s. |
| 586 |
3. Type ' +' to select any amount of consecutive spaces >1, |
| 587 |
then press Enter. |
| 588 |
4. Type c and change the matches to single spaces. |
| 589 |
|
| 590 |
--> This sentence has some extra spaces. |
| 591 |
This sentence has some extra spaces. |
| 592 |
|
| 593 |
Note: If you want to perform find-and-replace, the select |
| 594 |
command is the way to do it. Select the text you want |
| 595 |
to replace in — type % to select the whole file — and |
| 596 |
then perform the steps explained above. |
| 597 |
|
| 598 |
|
| 599 |
================================================================= |
| 600 |
= 5.4 ALIGN SELECTIONS = |
| 601 |
================================================================= |
| 602 |
|
| 603 |
Type & to align the contents of the selections. |
| 604 |
|
| 605 |
1. Move the cursor to the first line marked '-->' below. Place |
| 606 |
the cursor on the whitespace just after the arrow. |
| 607 |
2. Type C four times or 4C. |
| 608 |
3. Type W to select the numbers and brackets. |
| 609 |
4. Type & to align the words. |
| 610 |
|
| 611 |
--> 97) lorem |
| 612 |
--> 98) ipsum |
| 613 |
--> 99) dolor |
| 614 |
--> 100) sit |
| 615 |
--> 101) amet |
| 616 |
|
| 617 |
Note: & only cares about the alignment of the "head" of the |
| 618 |
selections - the end that moves. The other end is called |
| 619 |
the "anchor". |
| 620 |
|
| 621 |
================================================================= |
| 622 |
= 5.5 SPLIT SELECTION INTO LINES = |
| 623 |
================================================================= |
| 624 |
|
| 625 |
Press Alt-s to split the selection(s) on newlines. |
| 626 |
|
| 627 |
1. Move the cursor to the first row of the table below. |
| 628 |
2. Select the entire table with 6x. |
| 629 |
3. Press Alt-s to split into selections at each line. |
| 630 |
4. Align the table with &. |
| 631 |
|
| 632 |
| FRUIT | AMOUNT | |
| 633 |
|---------|--------| |
| 634 |
| Apples | 8 | |
| 635 |
| Bananas | 6 | |
| 636 |
| Oranges | 3 | |
| 637 |
| Donuts | 4 | |
| 638 |
|
| 639 |
Note: On macOS, you may need to configure your terminal to use |
| 640 |
Option as Alt (e.g. macos-option-as-alt = left). |
| 641 |
This is also true for future Alt- commands. |
| 642 |
|
| 643 |
================================================================= |
| 644 |
= CHAPTER 5 RECAP = |
| 645 |
================================================================= |
| 646 |
|
| 647 |
* Type C to duplicate the cursor to the next suitable line |
| 648 |
and Alt-C for previous suitable line. |
| 649 |
|
| 650 |
* Type s to select all instances of a regex pattern inside |
| 651 |
the current selection. |
| 652 |
|
| 653 |
* Type & to align selections. |
| 654 |
|
| 655 |
* Press Alt-s to split the selection into lines. |
| 656 |
|
| 657 |
|
| 658 |
|
| 659 |
|
| 660 |
|
| 661 |
|
| 662 |
|
| 663 |
|
| 664 |
|
| 665 |
================================================================= |
| 666 |
= 6.1 SELECTING TO A CHARACTER = |
| 667 |
================================================================= |
| 668 |
|
| 669 |
Type f<ch> to select up to and including (find) a character. |
| 670 |
Type t<ch> to do the same, but not including (till) a character. |
| 671 |
Type uppercase F / T to do the same backwards. |
| 672 |
|
| 673 |
1. Move the cursor to the line marked '-->' below. Place the |
| 674 |
cursor on the first dash. |
| 675 |
2. Type f[ to select to the square bracket. |
| 676 |
3. Type d to delete your selection. |
| 677 |
4. Go to the end of the line and repeat with F]. |
| 678 |
5. Move to the second line marked '-->', just after the arrow. |
| 679 |
6. Use t and T to delete the dashes around the sentence. |
| 680 |
|
| 681 |
--> -----[Free this sentence of its brackets!]----- |
| 682 |
--> ------Free this sentence of its dashes!------ |
| 683 |
|
| 684 |
Note: Unlike Vim, Helix doesn't limit these commands to the |
| 685 |
current line. It searches for the character in the file. |
| 686 |
|
| 687 |
================================================================= |
| 688 |
= 6.2 THE REPLACE COMMAND = |
| 689 |
================================================================= |
| 690 |
|
| 691 |
Type r<ch> to replace all selected characters with <ch>. |
| 692 |
|
| 693 |
1. Move to the second line of the table, place the cursor on the |
| 694 |
first =. |
| 695 |
2. Type t| (Shift-\) to select the = separator. |
| 696 |
3. Type r- to replace the separator with dashes. |
| 697 |
|
| 698 |
|
| 699 |
| Month | Days | |
| 700 |
|=======|------| |
| 701 |
| Jan | 31 | |
| 702 |
| Feb | 28 | |
| 703 |
| Mar | 31 | |
| 704 |
| ... | ... | |
| 705 |
|
| 706 |
|
| 707 |
|
| 708 |
|
| 709 |
================================================================= |
| 710 |
= 6.3 REPETITION = |
| 711 |
================================================================= |
| 712 |
|
| 713 |
Type . to repeat the last insert command. |
| 714 |
Press Alt-. to repeat the last f / t selection. |
| 715 |
|
| 716 |
1. Move the cursor to the line marked '-->' below. |
| 717 |
2. Make a change, insertion or appendage and repeat it with . . |
| 718 |
3. Try using Alt-. with f and t, to select multiple sentences |
| 719 |
for instance. |
| 720 |
|
| 721 |
--> This is some text for you to repeat things. You can repeat |
| 722 |
insertions like changing words, or repeat selections like |
| 723 |
f / t. |
| 724 |
|
| 725 |
|
| 726 |
|
| 727 |
|
| 728 |
|
| 729 |
|
| 730 |
|
| 731 |
================================================================= |
| 732 |
= CHAPTER 6 RECAP = |
| 733 |
================================================================= |
| 734 |
|
| 735 |
* Type f / F to extend selection up to & including a character. |
| 736 |
* Type t / T to extend selection until a character. |
| 737 |
|
| 738 |
* Type r to replace selected characters. |
| 739 |
|
| 740 |
* Type . to repeat the last insertion. |
| 741 |
* Press Alt-. to repeat the last f / t selection. |
| 742 |
|
| 743 |
|
| 744 |
|
| 745 |
|
| 746 |
|
| 747 |
|
| 748 |
|
| 749 |
|
| 750 |
|
| 751 |
|
| 752 |
|
| 753 |
================================================================= |
| 754 |
= 7.1 REPLACE WITH YANKED TEXT = |
| 755 |
================================================================= |
| 756 |
|
| 757 |
Type R to replace the selection with previously yanked text. |
| 758 |
|
| 759 |
1. Move the cursor to the line marked '-->' below. |
| 760 |
2. Type w to select "watermelons" and then y to yank it. |
| 761 |
3. Select "oranges" with w. |
| 762 |
4. Type R to replace "oranges" with "watermelons". |
| 763 |
|
| 764 |
|
| 765 |
--> I like watermelons because oranges are refreshing. |
| 766 |
I like watermelons because watermelons are refreshing. |
| 767 |
|
| 768 |
|
| 769 |
|
| 770 |
|
| 771 |
|
| 772 |
|
| 773 |
|
| 774 |
|
| 775 |
================================================================= |
| 776 |
= 7.2 JOINING LINES = |
| 777 |
================================================================= |
| 778 |
|
| 779 |
Type J to join together lines in selection. |
| 780 |
|
| 781 |
1. Move the cursor to the line marked '-->' below. |
| 782 |
2. Type x four times or 4x to select all four lines. |
| 783 |
3. Type J to join the lines together. |
| 784 |
|
| 785 |
--> This sentence |
| 786 |
is spilling over |
| 787 |
onto other |
| 788 |
lines. |
| 789 |
|
| 790 |
This sentence is spilling over onto other lines. |
| 791 |
|
| 792 |
|
| 793 |
|
| 794 |
|
| 795 |
|
| 796 |
|
| 797 |
================================================================= |
| 798 |
= 7.3 INDENTING LINES = |
| 799 |
================================================================= |
| 800 |
|
| 801 |
Type > to indent a line and < to unindent it. |
| 802 |
|
| 803 |
1. Move the cursor to the line marked '-->' below. |
| 804 |
2. Move down to the second line and type > to indent it. |
| 805 |
3. Move to the third line and type < to unindent it. |
| 806 |
|
| 807 |
--> These lines |
| 808 |
are indented |
| 809 |
very poorly. |
| 810 |
|
| 811 |
These lines |
| 812 |
are indented |
| 813 |
much better. |
| 814 |
|
| 815 |
|
| 816 |
|
| 817 |
|
| 818 |
|
| 819 |
================================================================= |
| 820 |
= 7.4 INCREMENTING AND DECREMENTING = |
| 821 |
================================================================= |
| 822 |
|
| 823 |
Press Ctrl-a to increment the number under selection. |
| 824 |
Press Ctrl-x to decrement the number under selection. |
| 825 |
|
| 826 |
1. Move the cursor to the third line marked '-->' below. |
| 827 |
2. Move the cursor onto the number 2, then press Ctrl-a. |
| 828 |
3. Move onto the number 3 on the next line and press Ctrl-a. |
| 829 |
4. Move onto the number 6 on the last line and press Ctrl-x. |
| 830 |
|
| 831 |
--> 1) First point. |
| 832 |
--> 2) Added point. |
| 833 |
--> 2) Next point. |
| 834 |
--> 3) Another point. |
| 835 |
--> 6) Last point. |
| 836 |
|
| 837 |
|
| 838 |
|
| 839 |
|
| 840 |
|
| 841 |
================================================================= |
| 842 |
= CHAPTER 7 RECAP = |
| 843 |
================================================================= |
| 844 |
|
| 845 |
* Type R to replace the selection with yanked text. |
| 846 |
|
| 847 |
* Type J to join lines in selection. |
| 848 |
|
| 849 |
* Type > and < to indent / unindent lines. |
| 850 |
|
| 851 |
* Press Ctrl-a to increment the selected number. |
| 852 |
* Press Ctrl-x to decrement the selected number. |
| 853 |
|
| 854 |
|
| 855 |
|
| 856 |
|
| 857 |
|
| 858 |
|
| 859 |
|
| 860 |
|
| 861 |
|
| 862 |
|
| 863 |
================================================================= |
| 864 |
= 8.1 REGISTERS = |
| 865 |
================================================================= |
| 866 |
|
| 867 |
Registers are containers identified by a character for storing |
| 868 |
things like yanked text. Registers are also used to store the |
| 869 |
most recent search term as well as macros, which you'll learn |
| 870 |
about in the next section. |
| 871 |
|
| 872 |
Type "<ch> to select register <ch>. |
| 873 |
|
| 874 |
1. Move the cursor to the line marked '-->' below. |
| 875 |
2. Type w to select "watermelons" and yank with y. |
| 876 |
3. Type w to select "bananas". |
| 877 |
4. Change to register b with "b and yank with y. |
| 878 |
5. Select "mangoes" and type R to replace it with "watermelons". |
| 879 |
6. Select "pineapples" then type "b R to replace with "bananas". |
| 880 |
|
| 881 |
--> I like watermelons and bananas because my favorite fruits |
| 882 |
are mangoes and pineapples. |
| 883 |
|
| 884 |
|
| 885 |
================================================================= |
| 886 |
= 8.2 MACROS = |
| 887 |
================================================================= |
| 888 |
|
| 889 |
Macros are a way to record a set of actions you want to repeat. |
| 890 |
You can also record macros to a specific register (default @). |
| 891 |
Type Q to start recording a macro - you should see a popup at |
| 892 |
the bottom of your screen. Type Q again to stop recording. |
| 893 |
Type q to repeat the macro from register @ (the default). |
| 894 |
|
| 895 |
1. Move the cursor to the first line marked '-->' below. |
| 896 |
Ensure your cursor is on the '>' of the arrow. |
| 897 |
2. Type Q to start recording. |
| 898 |
3. Edit the line to look like the bottom one. |
| 899 |
4. Exit insert and type Q again to stop recording. |
| 900 |
5. Move to the line below and put your cursor on '>' again. |
| 901 |
6. Type q to repeat the macro. |
| 902 |
|
| 903 |
--> ... sentence doesn't have its first and last ... . |
| 904 |
--> ... sentence doesn't have its first and last ... . |
| 905 |
This sentence doesn't have its first and last word. |
| 906 |
|
| 907 |
================================================================= |
| 908 |
= CHAPTER 8 RECAP = |
| 909 |
================================================================= |
| 910 |
|
| 911 |
* Type " to select a different register. |
| 912 |
|
| 913 |
* Type Q to start and stop recording a macro to a register, |
| 914 |
the default being @. |
| 915 |
|
| 916 |
* Type q to replay a macro from @ or the selected register. |
| 917 |
|
| 918 |
|
| 919 |
|
| 920 |
|
| 921 |
|
| 922 |
|
| 923 |
|
| 924 |
|
| 925 |
|
| 926 |
|
| 927 |
|
| 928 |
|
| 929 |
================================================================= |
| 930 |
= 9.1 SEARCHING FOR SELECTIONS = |
| 931 |
================================================================= |
| 932 |
|
| 933 |
The most recent search with / is stored in register /. |
| 934 |
n and N both refer to register /, this means we can set that |
| 935 |
register without having to type in a search. |
| 936 |
|
| 937 |
Type * to copy the selection into register /, setting the search |
| 938 |
term to the selection. This copies the primary selection, which |
| 939 |
you will learn about in the section on cycling selections. |
| 940 |
|
| 941 |
1. Move the cursor to the line marked '-->' below. |
| 942 |
2. Select "horse" with e and type *. |
| 943 |
3. Use n and N to jump between the instances of "horse". |
| 944 |
|
| 945 |
--> A horse is a horse, of course, of course, |
| 946 |
--> And no one can talk to a horse of course. |
| 947 |
|
| 948 |
Note: * is like a shorthand for "/y as all it really does is |
| 949 |
copy the selection into the / register. |
| 950 |
|
| 951 |
================================================================= |
| 952 |
= 9.2 ADDING SELECTION ON NEXT SEARCH MATCH = |
| 953 |
================================================================= |
| 954 |
|
| 955 |
A property of Select mode (v) when using n and N is that instead |
| 956 |
of moving the selection to the next match, it adds a new |
| 957 |
selection on each match. |
| 958 |
|
| 959 |
1. Move the cursor to the line marked '-->' below. |
| 960 |
2. Select the first "bat" and type * to set it to search. |
| 961 |
3. Type v to enter Select mode. |
| 962 |
4. Type n to select the other "bat". |
| 963 |
5. Use c (or r after selecting the "b"s) to change the "bat"s to |
| 964 |
"cat". |
| 965 |
|
| 966 |
--> Everybody wants to be a bat, |
| 967 |
--> because a cat's the only bat |
| 968 |
--> who knows where it's at. |
| 969 |
|
| 970 |
|
| 971 |
|
| 972 |
|
| 973 |
================================================================= |
| 974 |
= 9.3 USING THE JUMPLIST = |
| 975 |
================================================================= |
| 976 |
|
| 977 |
Helix can keep track of "jumps" which are big movements, like |
| 978 |
searching or jumping to the definition of a function in code. It |
| 979 |
stores these in what's called the jumplist. |
| 980 |
|
| 981 |
Press Ctrl-s to manually save your current position to |
| 982 |
the jumplist. |
| 983 |
|
| 984 |
Press Ctrl-i ("in") and Ctrl-o ("out") to move forward and |
| 985 |
backwards in the jumplist respectively. |
| 986 |
|
| 987 |
1. Press Ctrl-s somewhere. |
| 988 |
2. Move far away in the file. |
| 989 |
3. Press Ctrl-o (just once!) to come back to where you saved. |
| 990 |
|
| 991 |
|
| 992 |
|
| 993 |
|
| 994 |
|
| 995 |
================================================================= |
| 996 |
= 9.4 JUMP WITH TWO-CHARACTER LABELS = |
| 997 |
================================================================= |
| 998 |
|
| 999 |
Type gw to enable the 2-character labels. The start of each word |
| 1000 |
will be replaced by 2 highlighted characters. Type any sequence |
| 1001 |
of 2 highlighted characters to jump to the corresponding label, |
| 1002 |
or use ESC to drop the labels. |
| 1003 |
|
| 1004 |
The 2-character labels allow you to quickly jump to any location |
| 1005 |
in the viewable selection. |
| 1006 |
|
| 1007 |
1. Move the cursor to the start of the line marked '-->' below. |
| 1008 |
2. Press gw to enable the 2-character labels, and then the two |
| 1009 |
characters that replace the two letters 'he' at the start of |
| 1010 |
'here' to jump to the corresponding word. |
| 1011 |
|
| 1012 |
--> This is just a simple line of text. |
| 1013 |
There may be many such lines |
| 1014 |
But you really want to jump here! |
| 1015 |
This is fast with the 2-character labels. |
| 1016 |
|
| 1017 |
================================================================= |
| 1018 |
= CHAPTER 9 RECAP = |
| 1019 |
================================================================= |
| 1020 |
|
| 1021 |
* Type * to set the search register to the primary selection. |
| 1022 |
|
| 1023 |
* Type n / N in Select mode to add selections on each search |
| 1024 |
match. |
| 1025 |
|
| 1026 |
* Press Ctrl-s to save position to the jumplist. |
| 1027 |
* Press Ctrl-i and Ctrl-o to go forward and backward in the |
| 1028 |
jumplist. |
| 1029 |
|
| 1030 |
* Type gw to enable 2-character labels, and any 2 characters to |
| 1031 |
jump to the corresponding label, or ESC to drop the labels. |
| 1032 |
|
| 1033 |
|
| 1034 |
|
| 1035 |
|
| 1036 |
|
| 1037 |
|
| 1038 |
|
| 1039 |
================================================================= |
| 1040 |
= 10.1 CYCLING AND REMOVING SELECTIONS = |
| 1041 |
================================================================= |
| 1042 |
|
| 1043 |
Type ) and ( to cycle the primary selection forward and backward |
| 1044 |
through selections respectively. |
| 1045 |
|
| 1046 |
Press Alt-, to remove the primary selection. |
| 1047 |
|
| 1048 |
1. Move the cursor to the line marked '-->' below. |
| 1049 |
2. Select both lines with xx or 2x. |
| 1050 |
3. Type s to select, type "would" and enter. |
| 1051 |
4. Use ( and ) to cycle the primary selection and deselect |
| 1052 |
the second "would" with Alt-, . |
| 1053 |
5. Type c "wood" to change the remaining "would"s to "wood". |
| 1054 |
|
| 1055 |
--> How much would would a wouldchuck chuck |
| 1056 |
--> if a wouldchuck could chuck would? |
| 1057 |
|
| 1058 |
Note: The primary selection can be hard to see in some themes. |
| 1059 |
Check the status bar (bottom right) for the active index. |
| 1060 |
|
| 1061 |
================================================================= |
| 1062 |
= 10.2 CYCLING THE CONTENT OF SELECTIONS = |
| 1063 |
================================================================= |
| 1064 |
|
| 1065 |
Press Alt-) and Alt-( to cycle the content of the selections |
| 1066 |
forward and backward respectively. |
| 1067 |
|
| 1068 |
1. Move the cursor to the line marked '-->' below. |
| 1069 |
2. Select both lines with xx or 2x. |
| 1070 |
3. Type s to select, type "through|water|know" and enter. |
| 1071 |
4. Use Alt-( and Alt-) to cycle the content of the selections. |
| 1072 |
|
| 1073 |
--> Jumping through the water, |
| 1074 |
--> daring to know. |
| 1075 |
|
| 1076 |
|
| 1077 |
|
| 1078 |
|
| 1079 |
|
| 1080 |
|
| 1081 |
|
| 1082 |
|
| 1083 |
================================================================= |
| 1084 |
= 10.3 CHANGING CASE = |
| 1085 |
================================================================= |
| 1086 |
|
| 1087 |
Type ~ to switch the case of all selected letters. |
| 1088 |
Type ` to set all selected letters to lowercase. |
| 1089 |
Press Alt-` to set all selected letters to uppercase. |
| 1090 |
|
| 1091 |
1. Move the cursor to the first line marked '-->' below. |
| 1092 |
2. Select each wrongly capitalised or lowercase letter |
| 1093 |
and type ~ over them. |
| 1094 |
3. Move to the second line marked '-->'. |
| 1095 |
4. Type x to select the line. |
| 1096 |
5. Type ` to change the line to lowercase. |
| 1097 |
6. Move to the third line marked '-->'. |
| 1098 |
7. Type x to select the line. |
| 1099 |
8. Press Alt-` to change the line to uppercase. |
| 1100 |
|
| 1101 |
--> thIs sENtencE hAs MIS-cApitalIsed leTTerS. |
| 1102 |
--> this SENTENCE SHOULD all be in LOWERCASE. |
| 1103 |
--> THIS sentence should ALL BE IN uppercase! |
| 1104 |
|
| 1105 |
================================================================= |
| 1106 |
= 10.4 SPLITTING SELECTIONS = |
| 1107 |
================================================================= |
| 1108 |
|
| 1109 |
Type S to split each selection on a regex pattern. |
| 1110 |
|
| 1111 |
1. Move the cursor to the line under ---. |
| 1112 |
2. Type xx / 2x to select the lines. |
| 1113 |
3. Type S then \. |! Enter (note the spaces after . and !). |
| 1114 |
This effectively splits the selection into sentences at each |
| 1115 |
dot or exclamation mark. |
| 1116 |
4. Press Alt-; to reverse the selections. |
| 1117 |
5. Type ; to reduce selections to a single character - the first |
| 1118 |
letter of each sentence. |
| 1119 |
6. Press Alt-` to convert all selected letters to uppercase. |
| 1120 |
|
| 1121 |
--- |
| 1122 |
these are sentences. some sentences don't start with uppercase |
| 1123 |
letters! that is not good grammar. you can fix this. |
| 1124 |
|
| 1125 |
|
| 1126 |
|
| 1127 |
================================================================= |
| 1128 |
= CHAPTER 10 RECAP = |
| 1129 |
================================================================= |
| 1130 |
|
| 1131 |
* Use ) and ( to cycle the primary selection back and forward |
| 1132 |
through selections respectively. |
| 1133 |
* Press Alt-, to remove the primary selection. |
| 1134 |
* Press Alt-) and Alt-( to cycle the content of the selections. |
| 1135 |
|
| 1136 |
* Type ~ to alternate case of selected letters. |
| 1137 |
* Use ` and Alt-` to set the case of selected letters to |
| 1138 |
lower and upper respectively. |
| 1139 |
|
| 1140 |
* Type S to split selections on regex. |
| 1141 |
|
| 1142 |
|
| 1143 |
|
| 1144 |
|
| 1145 |
|
| 1146 |
|
| 1147 |
|
| 1148 |
|
| 1149 |
================================================================= |
| 1150 |
= 11.1 COMMENTING A LINE = |
| 1151 |
================================================================= |
| 1152 |
|
| 1153 |
Press Ctrl-c to comment the line under your cursor. |
| 1154 |
To uncomment the line, press Ctrl-c again. |
| 1155 |
|
| 1156 |
1. Move your cursor to the line marked '-->' below. |
| 1157 |
2. Now comment the line marked with '-->'. |
| 1158 |
3. Now try uncommenting the line. |
| 1159 |
|
| 1160 |
--> Comment me please |
| 1161 |
|
| 1162 |
|
| 1163 |
|
| 1164 |
|
| 1165 |
|
| 1166 |
|
| 1167 |
|
| 1168 |
|
| 1169 |
|
| 1170 |
|
| 1171 |
================================================================= |
| 1172 |
= 11.2 COMMENTING MULTIPLE LINES = |
| 1173 |
================================================================= |
| 1174 |
|
| 1175 |
Using the selections and multi-cursor functionality, you can |
| 1176 |
comment multiple lines as long as they are under the selection or |
| 1177 |
cursors. To uncomment the lines, press Ctrl-c again. |
| 1178 |
|
| 1179 |
1. Move your cursor to the line marked with '-->' below. |
| 1180 |
2. Now try to select or add more cursors to the other lines marked |
| 1181 |
with '-->'. |
| 1182 |
3. Comment those lines. |
| 1183 |
4. Uncomment those lines. |
| 1184 |
|
| 1185 |
--> What are you doing?! |
| 1186 |
--> Stop commenting me! |
| 1187 |
--> AAAAaargh!!! |
| 1188 |
--> Enough! Uncomment me now! |
| 1189 |
|
| 1190 |
Note: If there are only some commented lines under selections or |
| 1191 |
multiple cursors, they won't be uncommented but commented again. |
| 1192 |
|
| 1193 |
================================================================= |
| 1194 |
= CHAPTER 11 RECAP = |
| 1195 |
================================================================= |
| 1196 |
|
| 1197 |
* Use Ctrl-c to comment a line under your cursor. Press Ctrl-c |
| 1198 |
again to uncomment. |
| 1199 |
* To comment multiple lines, use the selections or multi-cursors |
| 1200 |
before typing Ctrl-c. Press Ctrl-c again to uncomment. |
| 1201 |
|
| 1202 |
|
| 1203 |
|
| 1204 |
|
| 1205 |
|
| 1206 |
|
| 1207 |
|
| 1208 |
|
| 1209 |
|
| 1210 |
|
| 1211 |
|
| 1212 |
|
| 1213 |
|
| 1214 |
|
| 1215 |
================================================================= |
| 1216 |
= 12.1 USING MATCH MODE JUMP = |
| 1217 |
================================================================= |
| 1218 |
|
| 1219 |
To switch to match mode from normal mode, type m. This feature |
| 1220 |
is particularly useful for handling bracket pairs and their |
| 1221 |
contents. |
| 1222 |
|
| 1223 |
There are several actions that can be performed in match mode, |
| 1224 |
as indicated by the help pop-up. To jump to a matching bracket pair, |
| 1225 |
simply press mm. For example on the lines below (starting with |
| 1226 |
-->), move the cursor in normal mode to (, and then press mm to jump |
| 1227 |
to the matching ). You can do the same on the line below: for example |
| 1228 |
move to ], and press mm to jump to [ . |
| 1229 |
|
| 1230 |
--> you can (jump between matching parentheses) |
| 1231 |
--> or between matching [ square brackets ] |
| 1232 |
--> now { you know the drill: this works with brackets too } |
| 1233 |
|
| 1234 |
|
| 1235 |
|
| 1236 |
|
| 1237 |
================================================================= |
| 1238 |
= 12.2 USING MATCH MODE SELECT INSIDE = |
| 1239 |
================================================================= |
| 1240 |
|
| 1241 |
Match mode also lets you select the "inside" content between a |
| 1242 |
pair of brackets or other delimiters. In the lines below: |
| 1243 |
|
| 1244 |
- move to the --> line, put your cursor in normal mode at any |
| 1245 |
location between the parentheses, for example at 'x', and press |
| 1246 |
mi( or mi) to select the whole content inside the parentheses |
| 1247 |
(parentheses excluded). As usual, you can then do anything you want |
| 1248 |
with the selection (for example, press c to change it) |
| 1249 |
|
| 1250 |
--> outside and (inside x parentheses) - and outside again |
| 1251 |
|
| 1252 |
Test below that you can do the same with [], or {}, or with |
| 1253 |
nested combinations of these (this will act on the immediately |
| 1254 |
surrounding matching pair). This also works with "" and similar |
| 1255 |
|
| 1256 |
--> test [ with square brackets ] ! |
| 1257 |
--> try ( with nested [ pairs of ( parentheses) and "brackets" ]) |
| 1258 |
|
| 1259 |
================================================================= |
| 1260 |
= 12.3 USING MATCH MODE SELECT AROUND = |
| 1261 |
================================================================= |
| 1262 |
|
| 1263 |
You can also select the "around" content, i.e. both the inside |
| 1264 |
content and the delimiters themselves, by using the ma select. |
| 1265 |
For example, move to the line under, move your cursor in normal |
| 1266 |
mode to any position between the (), and select the content of |
| 1267 |
the (), including the surrounding (), by typing ma( or ma). As |
| 1268 |
usual, you can do anything you want with the selection, for |
| 1269 |
example delete it all with ma(d . |
| 1270 |
|
| 1271 |
--> you ( select x around ) to include delimiters in the select |
| 1272 |
|
| 1273 |
This naturally works with other delimiters too: |
| 1274 |
|
| 1275 |
--> try [ with 'square' brackets ] too! |
| 1276 |
|
| 1277 |
|
| 1278 |
|
| 1279 |
|
| 1280 |
|
| 1281 |
================================================================= |
| 1282 |
= 12.4 USING MATCH MODE SURROUND = |
| 1283 |
================================================================= |
| 1284 |
|
| 1285 |
The match mode can also be used to add surrounding around the |
| 1286 |
current selection. For example, move to the line below, then: |
| 1287 |
* i) select the "select all of this" line segment (for example, |
| 1288 |
move in normal mode the cursor to the start of select, then enter |
| 1289 |
selection mode with v , then select the 4 next words with 4e ), |
| 1290 |
* ii) press ms( or ms) to surround the selection with a pair of |
| 1291 |
parentheses. |
| 1292 |
|
| 1293 |
--> so, select all of this, and surround it with () |
| 1294 |
|
| 1295 |
You can do the same with other delimiters: for example, ms' on |
| 1296 |
WORD below to surround it with a pair of ''. You can try also |
| 1297 |
with adding a surrounding pair of "", or {}, or []. |
| 1298 |
|
| 1299 |
--> surround this WORD ! |
| 1300 |
|
| 1301 |
|
| 1302 |
|
| 1303 |
================================================================= |
| 1304 |
= 12.5 USING MATCH MODE DELETE SURROUND = |
| 1305 |
================================================================= |
| 1306 |
|
| 1307 |
You can delete surrounding pair of delimiters with the md |
| 1308 |
command. On the line below, move the cursor anywhere |
| 1309 |
within the pair of (), for example to the 'x', then from there, |
| 1310 |
in normal mode, press md( or md) to delete the surrounding |
| 1311 |
pair of parentheses. |
| 1312 |
|
| 1313 |
--> delete (the x pair of parentheses) from within! |
| 1314 |
|
| 1315 |
You can naturally delete other kinds of surroundings: |
| 1316 |
|
| 1317 |
--> delete (nested [delimiters]): "this" will delete the nearest |
| 1318 |
matching surrounding pair. |
| 1319 |
--> delete "layers "of" quote marks" too: this will delete the |
| 1320 |
nearest previous and following quote marks |
| 1321 |
|
| 1322 |
Trying to delete nonexistent surrounding delimiters prints an error |
| 1323 |
at the bottom bar and does nothing. |
| 1324 |
|
| 1325 |
================================================================= |
| 1326 |
= 12.6 USING MATCH MODE REPLACE SURROUND = |
| 1327 |
================================================================= |
| 1328 |
|
| 1329 |
You can replace surrounding pairs of delimiters with the mr |
| 1330 |
command. On the line below, move the cursor to |
| 1331 |
anywhere within the pair of (), for example on the 'x', then in |
| 1332 |
normal mode, press mr([ to replace the pair of () with a pair |
| 1333 |
of []. |
| 1334 |
|
| 1335 |
--> replace the (pair from x within), with something else |
| 1336 |
|
| 1337 |
This command will act on the closest enclosing pair, so you |
| 1338 |
can try replacing different surrounding in the following: |
| 1339 |
|
| 1340 |
--> some (nested surroundings [can be replaced]) |
| 1341 |
--> this "works with 'other surroundings' too" |
| 1342 |
|
| 1343 |
You can try to replace a nonexistent pair: this will show |
| 1344 |
an error warning at the bottom bar and do nothing. |
| 1345 |
|
| 1346 |
|
| 1347 |
================================================================= |
| 1348 |
= CHAPTER 12 RECAP = |
| 1349 |
================================================================= |
| 1350 |
|
| 1351 |
You can enter the match mode with the m key; this will show the |
| 1352 |
actions available in a popup. This will allow you to: |
| 1353 |
* jump to matching pair of delimiters with mm (you must have a |
| 1354 |
delimiter belonging to a pair under your cursor) |
| 1355 |
* select inside a pair of delimiters surrounding your cursor |
| 1356 |
(i.e. select the content but not the delimiters) with mi( |
| 1357 |
and similar |
| 1358 |
* select around a pair of delimiters surrounding your cursor |
| 1359 |
(i.e. select the content and the delimiters) with ma( and |
| 1360 |
similar |
| 1361 |
* delete surrounding delimiters with md( and similar |
| 1362 |
* add surrounding delimiters around the selection with ms( |
| 1363 |
* replace a pair of delimiters surrounding your selection with |
| 1364 |
mr([ to replace for example surrounding () with [] |
| 1365 |
|
| 1366 |
|
| 1367 |
|
| 1368 |
|
| 1369 |
================================================================= |
| 1370 |
= CHAPTER 13.1 CREATE NEW SPLIT = |
| 1371 |
================================================================= |
| 1372 |
|
| 1373 |
In Normal mode, press Ctrl-w to open the Window menu, which displays |
| 1374 |
a list of available commands. |
| 1375 |
|
| 1376 |
To open a new empty buffer in a vertical split on the right half |
| 1377 |
of your current window, use Ctrl-w nv (i.e., press Ctrl |
| 1378 |
and w simultaneously, then press n, followed by v). Your current |
| 1379 |
window will now split in 2 vertically. A new empty buffer split |
| 1380 |
will appear on the right half and your cursor will jump to the |
| 1381 |
new vertical split. |
| 1382 |
|
| 1383 |
To create a new empty buffer in a horizontal split, press |
| 1384 |
Ctrl-w ns. This action divides your current window into two |
| 1385 |
horizontally, creates a new buffer, and moves your cursor to the |
| 1386 |
new horizontal split. |
| 1387 |
|
| 1388 |
|
| 1389 |
|
| 1390 |
|
| 1391 |
================================================================= |
| 1392 |
= CHAPTER 13.2 MOVE BETWEEN SPLITS = |
| 1393 |
================================================================= |
| 1394 |
|
| 1395 |
Use Ctrl-w k to move to the split above your current split. Use |
| 1396 |
Ctrl-w j to move to the split below. Use Ctrl-w h to move to |
| 1397 |
the split on the left and Ctrl-w l to move to the split on the |
| 1398 |
right. To navigate to the next split (in the order they were |
| 1399 |
opened), press Ctrl-w w. |
| 1400 |
|
| 1401 |
You can now do whatever you want in your new buffers and splits. |
| 1402 |
Once you are done with using your new buffer split, |
| 1403 |
you can close it with Ctrl-w q . Move to the bottom right split |
| 1404 |
with Ctrl-w l then Ctrl-w j, then press Ctrl-w q to close this |
| 1405 |
specific split. |
| 1406 |
|
| 1407 |
You can also close all splits except the current one with Ctrl-w o . |
| 1408 |
Open a third vertical split with Ctrl-w nv , then move to the |
| 1409 |
leftmost split with Ctrl-w h twice, then from inside the split on |
| 1410 |
the left press Ctrl-w o to close all except this split. |
| 1411 |
|
| 1412 |
|
| 1413 |
================================================================= |
| 1414 |
= CHAPTER 13.3 SPLIT CURRENT BUFFER = |
| 1415 |
================================================================= |
| 1416 |
|
| 1417 |
Use Ctrl-w s to split the view of the current buffer horizontally |
| 1418 |
and Ctrl-w v to split it vertically with the buffer opened in both |
| 1419 |
splits. |
| 1420 |
|
| 1421 |
Close extra splits with Ctrl-w o to return to a single window view. |
| 1422 |
|
| 1423 |
|
| 1424 |
|
| 1425 |
|
| 1426 |
|
| 1427 |
|
| 1428 |
|
| 1429 |
|
| 1430 |
|
| 1431 |
|
| 1432 |
|
| 1433 |
|
| 1434 |
|
| 1435 |
================================================================= |
| 1436 |
= CHAPTER 13.4 USE COMMANDS TO SPLIT = |
| 1437 |
================================================================= |
| 1438 |
|
| 1439 |
The :vsplit (or :vs for short) and :hsplit (or :hs) commands can |
| 1440 |
also be used to split a specific buffer vertically or horizontally. |
| 1441 |
For example, enter the command: |
| 1442 |
|
| 1443 |
:vs something |
| 1444 |
|
| 1445 |
to open a new vertical split named "something" to the right. Here, |
| 1446 |
"something" is not an existing file, so a new buffer with this name |
| 1447 |
will open; however, you can replace "something" with any file name |
| 1448 |
to open it in a new buffer. Similarly, you can enter the command: |
| 1449 |
|
| 1450 |
:hs some_more |
| 1451 |
|
| 1452 |
to open a new buffer named "some_more" in the lower half. |
| 1453 |
"some_more" could be any file or path to open this specific file |
| 1454 |
or path instead of a new empty buffer. |
| 1455 |
|
| 1456 |
|
| 1457 |
================================================================= |
| 1458 |
= CHAPTER 13.5 SWAPPING SPLITS = |
| 1459 |
================================================================= |
| 1460 |
|
| 1461 |
Open a split on the right with :vs hello1 and then a split below |
| 1462 |
with :hs hello2. |
| 1463 |
|
| 1464 |
From hello2, press Ctrl-w K to swap it with the split above. Now |
| 1465 |
hello2 is at the top while hello1 is at the bottom. |
| 1466 |
|
| 1467 |
Still from hello2, press Ctrl-w H to swap with the split on the |
| 1468 |
left: now hello2 is on the left and the tutor is on the top |
| 1469 |
right. After Ctrl-w you can use HJKL to swap with the buffer |
| 1470 |
on the left / below / above / on the right. |
| 1471 |
|
| 1472 |
Move back to the tutor split, and press Ctrl-w o to only keep |
| 1473 |
this split. |
| 1474 |
|
| 1475 |
|
| 1476 |
|
| 1477 |
|
| 1478 |
|
| 1479 |
================================================================= |
| 1480 |
= CHAPTER 13.6 TRANSPOSE SPLITS = |
| 1481 |
================================================================= |
| 1482 |
|
| 1483 |
Open a split on the right with :vs hello1 and then a split below |
| 1484 |
with :hs hello2. |
| 1485 |
|
| 1486 |
Move to the tutor split, then press Ctrl-w t to transpose the |
| 1487 |
vertical split opened from this window: now, hello1 and |
| 1488 |
hello2 are below, rather than to the right of, the tutor. Press |
| 1489 |
Ctrl-w t again to transpose back. |
| 1490 |
|
| 1491 |
Move to the hello1 split, then press Ctrl-w t to transpose the |
| 1492 |
horizontal split that was opened from this window: now hello2 |
| 1493 |
is on the right, rather than below, hello1. Press Ctrl-w t to |
| 1494 |
transpose back. |
| 1495 |
|
| 1496 |
Move back to the tutor split and press Ctrl-w o to close all but |
| 1497 |
the tutor window. |
| 1498 |
|
| 1499 |
|
| 1500 |
|
| 1501 |
================================================================= |
| 1502 |
= CHAPTER 13.7 OPEN SPLIT FROM FILEPICKER = |
| 1503 |
================================================================= |
| 1504 |
|
| 1505 |
Splits can also be opened directly from the file picker. Press |
| 1506 |
space f to open the file picker. From there, you can type in text |
| 1507 |
to perform file lookup with fuzzy matching, and use the arrows |
| 1508 |
up and down to move the selected file (indicated by the > symbol). |
| 1509 |
If you want to exit the file picker, press Escape. |
| 1510 |
|
| 1511 |
Select any file you like in the file picker. You could open it in |
| 1512 |
the current view by pressing enter (do not do this at present). |
| 1513 |
But you can also open it in a new split. Press Ctrl-v to open |
| 1514 |
the selected file in a new vertical split. Press space f again, |
| 1515 |
select any file you want, and press Ctrl-s to open it in a |
| 1516 |
horizontal split. |
| 1517 |
|
| 1518 |
Move back to the tutor split, and press Ctrl-w o to close all |
| 1519 |
splits except this one. |
| 1520 |
|
| 1521 |
|
| 1522 |
|
| 1523 |
================================================================= |
| 1524 |
= CHAPTER 13 RECAP = |
| 1525 |
================================================================= |
| 1526 |
|
| 1527 |
Splits can be used to display either the same buffer several times |
| 1528 |
or several buffers. To access the main windows and splits commands, |
| 1529 |
press Ctrl-w . You can move between splits with Ctrl-w hjkl , |
| 1530 |
you can close a split with Ctrl-w q , and you can close all but |
| 1531 |
the present split with Ctrl-w o . |
| 1532 |
|
| 1533 |
Splits can also be opened by using the :vs FILENAME and |
| 1534 |
:hs FILENAME commands. |
| 1535 |
|
| 1536 |
Splits can also be used directly from the file pickers, by using |
| 1537 |
Ctrl-v to open the file selected in a new vertical split, and |
| 1538 |
Ctrl-s in a horizontal split. |
| 1539 |
|
| 1540 |
|
| 1541 |
|
| 1542 |
|
| 1543 |
|
| 1544 |
|
| 1545 |
================================================================= |
| 1546 |
This tutorial is still a work-in-progress. |
| 1547 |
More sections are planned. |