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