1 TECLA(5) Standards, Environments, and Macros TECLA(5) 2 3 4 5 NAME 6 tecla, teclarc - User interface provided by the tecla library. 7 8 DESCRIPTION 9 This man page describes the command-line editing features that are 10 available to users of programs that read keyboard input via the tecla 11 library. Users of the tcsh shell will find the default key bindings 12 very familiar. Users of the bash shell will also find it quite 13 familiar, but with a few minor differences, most notably in how forward 14 and backward searches through the list of historical commands are 15 performed. There are two major editing modes, one with emacs-like key 16 bindings and another with vi-like key bindings. By default emacs mode 17 is enabled, but vi(1) mode can alternatively be selected via the user's 18 configuration file. This file can also be used to change the bindings 19 of individual keys to suit the user's preferences. By default, tab 20 completion is provided. If the application hasn't reconfigured this to 21 complete other types of symbols, then tab completion completes file 22 names. 23 24 Key Sequence Notation 25 In the rest of this man page, and also in all tecla configuration 26 files, key sequences are expressed as follows. 27 28 ^A or C-a 29 This is a 'CONTROL-A', entered by pressing the CONTROL key 30 at the same time as the 'A' key. 31 32 33 \E or M- 34 In key sequences, both of these notations can be entered 35 either by pressing the ESCAPE key, then the following key, 36 or by pressing the META key at the same time as the 37 following key. Thus the key sequence M-p can be typed in 38 two ways, by pressing the ESCAPE key, followed by pressing 39 'P', or by pressing the META key at the same time as 'P'. 40 41 42 up 43 This refers to the up-arrow key. 44 45 46 down 47 This refers to the down-arrow key. 48 49 50 left 51 This refers to the left-arrow key. 52 53 54 right 55 This refers to the right-arrow key. 56 57 58 a 59 This is just a normal 'A' key. 60 61 62 The Tecla Configuration File 63 By default, tecla looks for a file called .teclarc in your home 64 directory (ie. ~/.teclarc). If it finds this file, it reads it, 65 interpreting each line as defining a new key binding or an editing 66 configuration option. Since the emacs key-bindings are installed by 67 default, if you want to use the non-default vi editing mode, the most 68 important item to go in this file is the following line: 69 70 edit-mode vi 71 72 73 74 This will re-configure the default bindings for vi-mode. The complete 75 set of arguments that this command accepts are: 76 77 vi 78 Install key bindings like those of the vi editor. 79 80 81 emacs 82 Install key bindings like those of the emacs editor. This is 83 the default. 84 85 86 none 87 Use just the native line editing facilities provided by the 88 terminal driver. 89 90 91 92 To prevent the terminal bell from being rung, such as when an 93 unrecognized control-sequence is typed, place the following line in the 94 configuration file: 95 96 nobeep 97 98 99 100 An example of a key binding line in the configuration file is the 101 following. 102 103 bind M-[2~ insert-mode 104 105 106 107 On many keyboards, the above key sequence is generated when one presses 108 the insert key, so with this key binding, one can toggle between the 109 emacs-mode insert and overwrite modes by hitting one key. One could 110 also do it by typing out the above sequence of characters one by one. 111 As explained above, the M- part of this sequence can be typed either by 112 pressing the ESCAPE key before the following key, or by pressing the 113 META key at the same time as the following key. Thus if you had set the 114 above key binding, and the insert key on your keyboard didn't generate 115 the above key sequence, you could still type it in either of the 116 following 2 ways. 117 118 1. Hit the ESCAPE key momentarily, then press '[', then '2', 119 then finally '~'. 120 121 2. Press the META key at the same time as pressing the '[' key, 122 then press '2', then '~'. 123 124 125 If you set a key binding for a key sequence that is already bound to a 126 function, the new binding overrides the old one. If in the new binding 127 you omit the name of the new function to bind to the key sequence, the 128 original binding becomes undefined. 129 130 131 Starting with versions of libtecla later than 1.3.3 it is now possible 132 to bind key sequences that begin with a printable character. Previously 133 key sequences were required to start with a CONTROL or META character. 134 135 136 Note that the special keywords "up", "down", "left", and "right" refer 137 to the arrow keys, and are thus not treated as key sequences. So, for 138 example, to rebind the up and down arrow keys to use the history search 139 mechanism instead of the simple history recall method, you could place 140 the following in your configuration file: 141 142 bind up history-search-backwards 143 bind down history-search-backwards 144 145 146 147 To unbind an existing binding, you can do this with the bind command by 148 omitting to name any action to rebind the key sequence to. For example, 149 by not specifying an action function, the following command unbinds the 150 default beginning-of-line action from the ^A key sequence: 151 152 bind ^A 153 154 155 156 If you create a ~/.teclarc configuration file, but it appears to have 157 no effect on the program, check the documentation of the program to see 158 if the author chose a different name for this file. 159 160 Filename and Tilde Completion 161 With the default key bindings, pressing the TAB key (aka. ^I) results 162 in tecla attempting to complete the incomplete file name that precedes 163 the cursor. Tecla searches backwards from the cursor, looking for the 164 start of the file name, stopping when it hits either a space or the 165 start of the line. If more than one file has the specified prefix, then 166 tecla completes the file name up to the point at which the ambiguous 167 matches start to differ, then lists the possible matches. 168 169 170 In addition to literally written file names, tecla can complete files 171 that start with ~/ and ~user/ expressions and that contain $envvar 172 expressions. In particular, if you hit TAB within an incomplete ~user, 173 expression, tecla will attempt to complete the username, listing any 174 ambiguous matches. 175 176 177 The completion binding is implemented using the cpl_complete_word() 178 function, which is also available separately to users of this library. 179 See the cpl_complete_word(3TECLA) man page for more details. 180 181 Filename Expansion 182 With the default key bindings, pressing ^X* causes tecla to expand the 183 file name that precedes the cursor, replacing ~/ and ~user/ expressions 184 with the corresponding home directories, and replacing $envvar 185 expressions with the value of the specified environment variable, then 186 if there are any wildcards, replacing the so far expanded file name 187 with a space-separated list of the files which match the wild cards. 188 189 190 The expansion binding is implemented using the ef_expand_file() 191 function. See the ef_expand_file(3TECLA) man page for more details. 192 193 Recalling Previously Typed Lines 194 Every time that a new line is entered by the user, it is appended to a 195 list of historical input lines maintained within the GetLine resource 196 object. You can traverse up and down this list using the up and down 197 arrow keys. Alternatively, you can do the same with the ^P, and ^N 198 keys, and in vi command mode you can alternatively use the k and j 199 characters. Thus pressing up-arrow once, replaces the current input 200 line with the previously entered line. Pressing up-arrow again, 201 replaces this with the line that was entered before it, etc.. Having 202 gone back one or more lines into the history list, one can return to 203 newer lines by pressing down-arrow one or more times. If you do this 204 sufficient times, you will return to the original line that you were 205 entering when you first hit up-arrow. 206 207 208 Note that in vi mode, all of the history recall functions switch the 209 library into command mode. 210 211 212 In emacs mode the M-p and M-n keys work just like the ^P and ^N keys, 213 except that they skip all but those historical lines which share the 214 prefix that precedes the cursor. In vi command mode the upper case 'K' 215 and 'J' characters do the same thing, except that the string that they 216 search for includes the character under the cursor as well as what 217 precedes it. 218 219 220 Thus for example, suppose that you were in emacs mode, and you had just 221 entered the following list of commands in the order shown: 222 223 ls ~/tecla/ 224 cd ~/tecla 225 ls -l getline.c 226 emacs ~/tecla/getline.c 227 228 229 230 If you next typed: 231 232 ls 233 234 235 236 and then hit M-p, then rather than returning the previously typed emacs 237 line, which doesn't start with "ls", tecla would recall the "ls -l 238 getline.c" line. Pressing M-p again would recall the "ls ~/tecla/" 239 line. 240 241 242 Note that if the string that you are searching for, contains any of the 243 special characters, *, ?, or '[', then it is interpreted as a pattern 244 to be matched. Thus, continuing with the above example, after typing 245 in the list of commands shown, if you then typed: 246 247 *tecla* 248 249 250 251 and hit M-p, then the "emacs ~/tecla/getline.c" line would be recalled 252 first, since it contains the word tecla somewhere in the line, 253 Similarly, hitting M-p again, would recall the "ls ~/tecla/" line, and 254 hitting it once more would recall the "ls ~/tecla/" line. The pattern 255 syntax is the same as that described for file name expansion, in the 256 ef_expand_file(3TECLA). 257 258 History Files 259 Authors of programs that use the tecla library have the option of 260 saving historical command-lines in a file before exiting, and 261 subsequently reading them back in from this file when the program is 262 next started. There is no standard name for this file, since it makes 263 sense for each application to use its own history file, so that 264 commands from different applications don't get mixed up. 265 266 International Character Sets 267 Since libtecla version 1.4.0, tecla has been 8-bit clean. This means 268 that all 8-bit characters that are printable in the user's current 269 locale are now displayed verbatim and included in the returned input 270 line. Assuming that the calling program correctly contains a call like 271 the following, 272 273 setlocale(LC_CTYPE, ""); 274 275 276 277 then the current locale is determined by the first of the environment 278 variables LC_CTYPE, LC_ALL, and LANG, that is found to contain a valid 279 locale name. If none of these variables are defined, or the program 280 neglects to call setlocale, then the default C locale is used, which is 281 US 7-bit ASCII. On most unix-like platforms, you can get a list of 282 valid locales by typing the command: 283 284 locale -a 285 286 287 288 at the shell prompt. 289 290 Meta Keys and Locales 291 Beware that in most locales other than the default C locale, META 292 characters become printable, and they are then no longer considered to 293 match M-c style key bindings. This allows international characters to 294 be entered with the compose key without unexpectedly triggering META 295 key bindings. You can still invoke META bindings, since there are 296 actually two ways to do this. For example the binding M-c can also be 297 invoked by pressing the ESCAPE key momentarily, then pressing the c 298 key, and this will work regardless of locale. Moreover, many modern 299 terminal emulators, such as gnome's gnome-terminal's and KDE's konsole 300 terminals, already generate escape pairs like this when you use the 301 META key, rather than a real meta character, and other emulators 302 usually have a way to request this behavior, so you can continue to use 303 the META key on most systems. 304 305 306 For example, although xterm terminal emulators generate real 8-bit meta 307 characters by default when you use the META key, they can be configured 308 to output the equivalent escape pair by setting their EightBitInput X 309 resource to False. You can either do this by placing a line like the 310 following in your ~/.Xdefaults file, 311 312 XTerm*EightBitInput: False 313 314 315 316 or by starting an xterm with an -xrm '*EightBitInput: False' command- 317 line argument. In recent versions of xterm you can toggle this feature 318 on and off with the 'Meta Sends Escape' option in the menu that is 319 displayed when you press the left mouse button and the CONTROL key 320 within an xterm window. In CDE, dtterms can be similarly coerced to 321 generate escape pairs in place of meta characters, by setting the 322 Dtterm*KshMode resource to True. 323 324 Entering International Characters 325 If you don't have a keyboard that generates all of the international 326 characters that you need, there is usually a compose key that will 327 allow you to enter special characters, or a way to create one. For 328 example, under X windows on unix-like systems, if your keyboard doesn't 329 have a compose key, you can designate a redundant key to serve this 330 purpose with the xmodmap command. For example, on many PC keyboards 331 there is a microsoft-windows key, which is otherwise useless under 332 Linux. On a laptop, for example, the xev program might report that 333 pressing this key generates keycode 115. To turn this key into a 334 COMPOSE key, do the following: 335 336 xmodmap -e 'keycode 115 = Multi_key' 337 338 339 340 Type this key followed by a " character to enter an 'I' with a umlaut 341 over it. 342 343 The Available Key Binding Functions 344 The following is a list of the editing functions provided by the tecla 345 library. The names in the leftmost column of the list can be used in 346 configuration files to specify which function a given key or 347 combination of keys should invoke. They are also used in the next two 348 sections to list the default key bindings in emacs and vi modes. 349 350 user-interrupt 351 Send a SIGINT signal to the parent 352 process. 353 354 355 suspend 356 Suspend the parent process. 357 358 359 stop-output 360 Pause terminal output. 361 362 363 start-output 364 Resume paused terminal output. 365 366 367 literal-next 368 Arrange for the next character to be 369 treated as a normal character. This 370 allows control characters to be entered. 371 372 373 cursor-right 374 Move the cursor one character right. 375 376 377 cursor-left 378 Move the cursor one character left. 379 380 381 insert-mode 382 Toggle between insert mode and overwrite 383 mode. 384 385 386 beginning-of-line 387 Move the cursor to the beginning of the 388 line. 389 390 391 end-of-line 392 Move the cursor to the end of the line. 393 394 395 delete-line 396 Delete the contents of the current line. 397 398 399 kill-line 400 Delete everything that follows the 401 cursor. 402 403 404 backward-kill-line 405 Delete all characters between the cursor 406 and the start of the line. 407 408 409 forward-word 410 Move to the end of the word which follows 411 the cursor. 412 413 414 forward-to-word 415 Move the cursor to the start of the word 416 that follows the cursor. 417 418 419 backward-word 420 Move to the start of the word which 421 precedes the cursor. 422 423 424 goto-column 425 Move the cursor to the 1-relative column 426 in the line specified by any preceding 427 digit-argument sequences (see Entering 428 Repeat Counts below). 429 430 431 find-parenthesis 432 If the cursor is currently over a 433 parenthesis character, move it to the 434 matching parenthesis character. If not 435 over a parenthesis character move right 436 to the next close parenthesis. 437 438 439 forward-delete-char 440 Delete the character under the cursor. 441 442 443 backward-delete-char 444 Delete the character which precedes the 445 cursor. 446 447 448 list-or-eof 449 This is intended for binding to ^D. When 450 invoked when the cursor is within the 451 line it displays all possible completions 452 then redisplays the line unchanged. When 453 invoked on an empty line, it signals end- 454 of-input (EOF) to the caller of 455 gl_get_line(). 456 457 458 del-char-or-list-or-eof 459 This is intended for binding to ^D. When 460 invoked when the cursor is within the 461 line it invokes forward-delete-char. When 462 invoked at the end of the line it 463 displays all possible completions then 464 redisplays the line unchanged. When 465 invoked on an empty line, it signals end- 466 of-input (EOF) to the caller of 467 gl_get_line(). 468 469 470 forward-delete-word 471 Delete the word which follows the cursor. 472 473 474 backward-delete-word 475 Delete the word which precedes the 476 cursor. 477 478 479 upcase-word 480 Convert all of the characters of the word 481 which follows the cursor, to upper case. 482 483 484 downcase-word 485 Convert all of the characters of the word 486 which follows the cursor, to lower case. 487 488 489 capitalize-word 490 Capitalize the word which follows the 491 cursor. 492 493 494 change-case 495 If the next character is upper case, 496 toggle it to lower case and vice versa. 497 498 499 redisplay 500 Redisplay the line. 501 502 503 clear-screen 504 Clear the terminal, then redisplay the 505 current line. 506 507 508 transpose-chars 509 Swap the character under the cursor with 510 the character just before the cursor. 511 512 513 set-mark 514 Set a mark at the position of the cursor. 515 516 517 exchange-point-and-mark 518 Move the cursor to the last mark that was 519 set, and move the mark to where the 520 cursor used to be. 521 522 523 kill-region 524 Delete the characters that lie between 525 the last mark that was set, and the 526 cursor. 527 528 529 copy-region-as-kill 530 Copy the text between the mark and the 531 cursor to the cut buffer, without 532 deleting the original text. 533 534 535 yank 536 Insert the text that was last deleted, 537 just before the current position of the 538 cursor. 539 540 541 append-yank 542 Paste the current contents of the cut 543 buffer, after the cursor. 544 545 546 up-history 547 Recall the next oldest line that was 548 entered. Note that in vi mode you are 549 left in command mode. 550 551 552 down-history 553 Recall the next most recent line that was 554 entered. If no history recall session is 555 currently active, the next line from a 556 previous recall session is recalled. 557 Note that in vi mode you are left in 558 command mode. 559 560 561 history-search-backward 562 Recall the next oldest line who's prefix 563 matches the string which currently 564 precedes the cursor (in vi command-mode 565 the character under the cursor is also 566 included in the search string). Note that 567 in vi mode you are left in command mode. 568 569 570 history-search-forward 571 Recall the next newest line who's prefix 572 matches the string which currently 573 precedes the cursor (in vi command-mode 574 the character under the cursor is also 575 included in the search string). Note that 576 in vi mode you are left in command mode. 577 578 579 history-re-search-backward 580 Recall the next oldest line who's prefix 581 matches that established by the last 582 invocation of either history-search- 583 forward or history-search-backward. 584 585 586 history-re-search-forward 587 Recall the next newest line who's prefix 588 matches that established by the last 589 invocation of either history-search- 590 forward or history-search-backward. 591 592 593 complete-word 594 Attempt to complete the incomplete word 595 which precedes the cursor. Unless the 596 host program has customized word 597 completion, file name completion is 598 attempted. In vi command mode the 599 character under the cursor is also 600 included in the word being completed, and 601 you are left in vi insert mode. 602 603 604 expand-filename 605 Within the command line, expand wild 606 cards, tilde expressions and dollar 607 expressions in the file name which 608 immediately precedes the cursor. In vi 609 command mode the character under the 610 cursor is also included in the file name 611 being expanded, and you are left in vi 612 insert mode. 613 614 615 list-glob 616 List any file names which match the wild- 617 card, tilde and dollar expressions in the 618 file name which immediately precedes the 619 cursor, then redraw the input line 620 unchanged. 621 622 623 list-history 624 Display the contents of the history list 625 for the current history group. If a 626 repeat count of > 1 is specified, only 627 that many of the most recent lines are 628 displayed. See the Entering Repeat Counts 629 section. 630 631 632 read-from-file 633 Temporarily switch to reading input from 634 the file who's name precedes the cursor. 635 636 637 read-init-files 638 Re-read teclarc configuration files. 639 640 641 beginning-of-history 642 Move to the oldest line in the history 643 list. Note that in vi mode you are left 644 in command mode. 645 646 647 end-of-history 648 Move to the newest line in the history 649 list (ie. the current line). Note that in 650 vi mode this leaves you in command mode. 651 652 653 digit-argument 654 Enter a repeat count for the next key 655 binding function. For details, see the 656 Entering Repeat Counts section. 657 658 659 newline 660 Terminate and return the current contents 661 of the line, after appending a newline 662 character. The newline character is 663 normally '\n', but will be the first 664 character of the key sequence that 665 invoked the newline action, if this 666 happens to be a printable character. If 667 the action was invoked by the '\n' 668 newline character or the '\r' carriage 669 return character, the line is appended to 670 the history buffer. 671 672 673 repeat-history 674 Return the line that is being edited, 675 then arrange for the next most recent 676 entry in the history buffer to be 677 recalled when tecla is next called. 678 Repeatedly invoking this action causes 679 successive historical input lines to be 680 re-executed. Note that this action is 681 equivalent to the 'Operate' action in 682 ksh. 683 684 685 ring-bell 686 Ring the terminal bell, unless the bell 687 has been silenced via the nobeep 688 configuration option (see The Tecla 689 Configuration File section). 690 691 692 forward-copy-char 693 Copy the next character into the cut 694 buffer (NB. use repeat counts to copy 695 more than one). 696 697 698 backward-copy-char 699 Copy the previous character into the cut 700 buffer. 701 702 703 forward-copy-word 704 Copy the next word into the cut buffer. 705 706 707 backward-copy-word 708 Copy the previous word into the cut 709 buffer. 710 711 712 forward-find-char 713 Move the cursor to the next occurrence of 714 the next character that you type. 715 716 717 backward-find-char 718 Move the cursor to the last occurrence of 719 the next character that you type. 720 721 722 forward-to-char 723 Move the cursor to the character just 724 before the next occurrence of the next 725 character that the user types. 726 727 728 backward-to-char 729 Move the cursor to the character just 730 after the last occurrence before the 731 cursor of the next character that the 732 user types. 733 734 735 repeat-find-char 736 Repeat the last backward-find-char, 737 forward-find-char, backward-to-char or 738 forward-to-char. 739 740 741 invert-refind-char 742 Repeat the last backward-find-char, 743 forward-find-char, backward-to-char, or 744 forward-to-char in the opposite 745 direction. 746 747 748 delete-to-column 749 Delete the characters from the cursor up 750 to the column that is specified by the 751 repeat count. 752 753 754 delete-to-parenthesis 755 Delete the characters from the cursor up 756 to and including the matching 757 parenthesis, or next close parenthesis. 758 759 760 forward-delete-find 761 Delete the characters from the cursor up 762 to and including the following occurrence 763 of the next character typed. 764 765 766 backward-delete-find 767 Delete the characters from the cursor up 768 to and including the preceding occurrence 769 of the next character typed. 770 771 772 forward-delete-to 773 Delete the characters from the cursor up 774 to, but not including, the following 775 occurrence of the next character typed. 776 777 778 backward-delete-to 779 Delete the characters from the cursor up 780 to, but not including, the preceding 781 occurrence of the next character typed. 782 783 784 delete-refind 785 Repeat the last *-delete-find or 786 *-delete-to action. 787 788 789 delete-invert-refind 790 Repeat the last *-delete-find or 791 *-delete-to action, in the opposite 792 direction. 793 794 795 copy-to-column 796 Copy the characters from the cursor up to 797 the column that is specified by the 798 repeat count, into the cut buffer. 799 800 801 copy-to-parenthesis 802 Copy the characters from the cursor up to 803 and including the matching parenthesis, 804 or next close parenthesis, into the cut 805 buffer. 806 807 808 forward-copy-find 809 Copy the characters from the cursor up to 810 and including the following occurrence of 811 the next character typed, into the cut 812 buffer. 813 814 815 backward-copy-find 816 Copy the characters from the cursor up to 817 and including the preceding occurrence of 818 the next character typed, into the cut 819 buffer. 820 821 822 forward-copy-to 823 Copy the characters from the cursor up 824 to, but not including, the following 825 occurrence of the next character typed, 826 into the cut buffer. 827 828 829 backward-copy-to 830 Copy the characters from the cursor up 831 to, but not including, the preceding 832 occurrence of the next character typed, 833 into the cut buffer. 834 835 836 copy-refind 837 Repeat the last *-copy-find or *-copy-to 838 action. 839 840 841 copy-invert-refind 842 Repeat the last *-copy-find or *-copy-to 843 action, in the opposite direction. 844 845 846 vi-mode 847 Switch to vi mode from emacs mode. 848 849 850 emacs-mode 851 Switch to emacs mode from vi mode. 852 853 854 vi-insert 855 From vi command mode, switch to insert 856 mode. 857 858 859 vi-overwrite 860 From vi command mode, switch to overwrite 861 mode. 862 863 864 vi-insert-at-bol 865 From vi command mode, move the cursor to 866 the start of the line and switch to 867 insert mode. 868 869 870 vi-append-at-eol 871 From vi command mode, move the cursor to 872 the end of the line and switch to append 873 mode. 874 875 876 vi-append 877 From vi command mode, move the cursor one 878 position right, and switch to insert 879 mode. 880 881 882 vi-replace-char 883 From vi command mode, replace the 884 character under the cursor with the next 885 character entered. 886 887 888 vi-forward-change-char 889 From vi command mode, delete the next 890 character then enter insert mode. 891 892 893 vi-backward-change-char 894 From vi command mode, delete the 895 preceding character then enter insert 896 mode. 897 898 899 vi-forward-change-word 900 From vi command mode, delete the next 901 word then enter insert mode. 902 903 904 vi-backward-change-word 905 From vi command mode, delete the 906 preceding word then enter insert mode. 907 908 909 vi-change-rest-of-line 910 From vi command mode, delete from the 911 cursor to the end of the line, then enter 912 insert mode. 913 914 915 vi-change-line 916 From vi command mode, delete the current 917 line, then enter insert mode. 918 919 920 vi-change-to-bol 921 From vi command mode, delete all 922 characters between the cursor and the 923 beginning of the line, then enter insert 924 mode. 925 926 927 vi-change-to-column 928 From vi command mode, delete the 929 characters from the cursor up to the 930 column that is specified by the repeat 931 count, then enter insert mode. 932 933 934 vi-change-to-parenthesis 935 Delete the characters from the cursor up 936 to and including the matching 937 parenthesis, or next close parenthesis, 938 then enter vi insert mode. 939 940 941 vi-forward-change-find 942 From vi command mode, delete the 943 characters from the cursor up to and 944 including the following occurrence of the 945 next character typed, then enter insert 946 mode. 947 948 949 vi-backward-change-find 950 From vi command mode, delete the 951 characters from the cursor up to and 952 including the preceding occurrence of the 953 next character typed, then enter insert 954 mode. 955 956 957 vi-forward-change-to 958 From vi command mode, delete the 959 characters from the cursor up to, but not 960 including, the following occurrence of 961 the next character typed, then enter 962 insert mode. 963 964 965 vi-backward-change-to 966 From vi command mode, delete the 967 characters from the cursor up to, but not 968 including, the preceding occurrence of 969 the next character typed, then enter 970 insert mode. 971 972 973 vi-change-refind 974 Repeat the last vi-*-change-find or 975 vi-*-change-to action. 976 977 978 vi-change-invert-refind 979 Repeat the last vi-*-change-find or 980 vi-*-change-to action, in the opposite 981 direction. 982 983 984 vi-undo 985 In vi mode, undo the last editing 986 operation. 987 988 989 vi-repeat-change 990 In vi command mode, repeat the last 991 command that modified the line. 992 993 994 Default Key Bindings In emacs Mode 995 The following default key bindings, which can be overriden by the tecla 996 configuration file, are designed to mimic most of the bindings of the 997 unix tcsh shell shell, when it is in emacs editing mode. 998 999 1000 This is the default editing mode of the tecla library. 1001 1002 1003 Under UNIX the terminal driver sets a number of special keys for 1004 certain functions. The tecla library attempts to use the same key 1005 bindings to maintain consistency. The key sequences shown for the 1006 following 6 bindings are thus just examples of what they will probably 1007 be set to. If you have used the stty command to change these keys, then 1008 the default bindings should match. 1009 1010 ^C 1011 user-interrupt 1012 1013 1014 ^\ 1015 abort 1016 1017 1018 ^Z 1019 suspend 1020 1021 1022 ^Q 1023 start-output 1024 1025 1026 ^S 1027 stop-output 1028 1029 1030 ^V 1031 literal-next 1032 1033 1034 1035 The cursor keys are referred to by name, as follows. This is necessary 1036 because different types of terminals generate different key sequences 1037 when their cursor keys are pressed. 1038 1039 right 1040 cursor-right 1041 1042 1043 left 1044 cursor-left 1045 1046 1047 up 1048 up-history 1049 1050 1051 down 1052 down-history 1053 1054 1055 1056 The remaining bindings don't depend on the terminal settings. 1057 1058 ^F 1059 cursor-right 1060 1061 1062 ^B 1063 cursor-left 1064 1065 1066 M-i 1067 insert-mode 1068 1069 1070 ^A 1071 beginning-of-line 1072 1073 1074 ^E 1075 end-of-line 1076 1077 1078 ^U 1079 delete-line 1080 1081 1082 ^K 1083 kill-line 1084 1085 1086 M-f 1087 forward-word 1088 1089 1090 M-b 1091 backward-word 1092 1093 1094 ^D 1095 del-char-or-list-or-eof 1096 1097 1098 ^H 1099 backward-delete-char 1100 1101 1102 ^? 1103 backward-delete-char 1104 1105 1106 M-d 1107 forward-delete-word 1108 1109 1110 M-^H 1111 backward-delete-word 1112 1113 1114 M-^? 1115 backward-delete-word 1116 1117 1118 M-u 1119 upcase-word 1120 1121 1122 M-l 1123 downcase-word 1124 1125 1126 M-c 1127 capitalize-word 1128 1129 1130 ^R 1131 redisplay 1132 1133 1134 ^L 1135 clear-screen 1136 1137 1138 ^T 1139 transpose-chars 1140 1141 1142 ^@ 1143 set-mark 1144 1145 1146 ^X^X 1147 exchange-point-and-mark 1148 1149 1150 ^W 1151 kill-region 1152 1153 1154 M-w 1155 copy-region-as-kill 1156 1157 1158 ^Y 1159 yank 1160 1161 1162 ^P 1163 up-history 1164 1165 1166 ^N 1167 down-history 1168 1169 1170 M-p 1171 history-search-backward 1172 1173 1174 M-n 1175 history-search-forward 1176 1177 1178 ^I 1179 complete-word 1180 1181 1182 ^X* 1183 expand-filename 1184 1185 1186 ^X^F 1187 read-from-file 1188 1189 1190 ^X^R 1191 read-init-files 1192 1193 1194 ^Xg 1195 list-glob 1196 1197 1198 ^Xh 1199 list-history 1200 1201 1202 M-< 1203 beginning-of-history 1204 1205 1206 M-> 1207 end-of-history 1208 1209 1210 \n 1211 newline 1212 1213 1214 \r 1215 newline 1216 1217 1218 M-o 1219 repeat-history 1220 1221 1222 M-^V 1223 vi-mode 1224 1225 1226 M-0, M-1, ... M-9 1227 digit-argument (see below) 1228 1229 1230 1231 Note that ^I is what the TAB key generates, and that ^@ can be 1232 generated not only by pressing the CONTROL key and the @ key 1233 simultaneously, but also by pressing the CONTROL key and the space bar 1234 at the same time. 1235 1236 Default Key Bindings in vi Mode 1237 The following default key bindings are designed to mimic the vi style 1238 of editing as closely as possible. This means that very few editing 1239 functions are provided in the initial character input mode, editing 1240 functions instead being provided by the vi command mode. The vi command 1241 mode is entered whenever the ESCAPE character is pressed, or whenever a 1242 key sequence that starts with a meta character is entered. In addition 1243 to mimicing vi, libtecla provides bindings for tab completion, wild- 1244 card expansion of file names, and historical line recall. 1245 1246 1247 To learn how to tell the tecla library to use vi mode instead of the 1248 default emacs editing mode, see the earlier section entitled The Tecla 1249 Configuration File. 1250 1251 1252 Under UNIX the terminal driver sets a number of special keys for 1253 certain functions. The tecla library attempts to use the same key 1254 bindings to maintain consistency, binding them both in input mode and 1255 in command mode. The key sequences shown for the following 6 bindings 1256 are thus just examples of what they will probably be set to. If you 1257 have used the stty command to change these keys, then the default 1258 bindings should match. 1259 1260 ^C 1261 user-interrupt 1262 1263 1264 ^\ 1265 abort 1266 1267 1268 ^Z 1269 suspend 1270 1271 1272 ^Q 1273 start-output 1274 1275 1276 ^S 1277 stop-output 1278 1279 1280 ^V 1281 literal-next 1282 1283 1284 M-^C 1285 user-interrupt 1286 1287 1288 M-^\ 1289 abort 1290 1291 1292 M-^Z 1293 suspend 1294 1295 1296 M-^Q 1297 start-output 1298 1299 1300 M-^S 1301 stop-output 1302 1303 1304 1305 Note that above, most of the bindings are defined twice, once as a raw 1306 control code like ^C and then a second time as a META character like 1307 M-^C. The former is the binding for vi input mode, whereas the latter 1308 is the binding for vi command mode. Once in command mode all key 1309 sequences that the user types that they don't explicitly start with an 1310 ESCAPE or a META key, have their first key secretly converted to a META 1311 character before the key sequence is looked up in the key binding 1312 table. Thus, once in command mode, when you type the letter i, for 1313 example, the tecla library actually looks up the binding for M-i. 1314 1315 1316 The cursor keys are referred to by name, as follows. This is necessary 1317 because different types of terminals generate different key sequences 1318 when their cursor keys are pressed. 1319 1320 right 1321 cursor-right 1322 1323 1324 left 1325 cursor-left 1326 1327 1328 up 1329 up-history 1330 1331 1332 down 1333 down-history 1334 1335 1336 1337 The cursor keys normally generate a key sequence that start with an 1338 ESCAPE character, so beware that using the arrow keys will put you into 1339 command mode (if you aren't already in command mode). 1340 1341 1342 The following are the terminal-independent key bindings for vi input 1343 mode. 1344 1345 ^D 1346 list-or-eof 1347 1348 1349 ^G 1350 list-glob 1351 1352 1353 ^H 1354 backward-delete-char 1355 1356 1357 ^I 1358 complete-word 1359 1360 1361 \r 1362 newline 1363 1364 1365 \n 1366 newline 1367 1368 1369 ^L 1370 clear-screen 1371 1372 1373 ^N 1374 down-history 1375 1376 1377 ^P 1378 up-history 1379 1380 1381 ^R 1382 redisplay 1383 1384 1385 ^U 1386 backward-kill-line 1387 1388 1389 ^W 1390 backward-delete-word 1391 1392 1393 ^X* 1394 expand-filename 1395 1396 1397 ^X^F 1398 read-from-file 1399 1400 1401 ^X^R 1402 read-init-files 1403 1404 1405 ^? 1406 backward-delete-char 1407 1408 1409 1410 The following are the key bindings that are defined in vi command mode, 1411 this being specified by them all starting with a META character. As 1412 mentioned above, once in command mode the initial meta character is 1413 optional. For example, you might enter command mode by typing ESCAPE, 1414 and then press 'H' twice to move the cursor two positions to the left. 1415 Both 'H' characters get quietly converted to M-h before being compared 1416 to the key binding table, the first one because ESCAPE followed by a 1417 character is always converted to the equivalent META character, and the 1418 second because command mode was already active. 1419 1420 M-<space> 1421 cursor-right (META-space) 1422 1423 1424 M-$ 1425 end-of-line 1426 1427 1428 M-* 1429 expand-filename 1430 1431 1432 M-+ 1433 down-history 1434 1435 1436 M-- 1437 up-history 1438 1439 1440 M-< 1441 beginning-of-history 1442 1443 1444 M-> 1445 end-of-history 1446 1447 1448 M-^ 1449 beginning-of-line 1450 1451 1452 M- 1453 repeat-find-char 1454 1455 1456 M-, 1457 invert-refind-char 1458 1459 1460 M-| 1461 goto-column 1462 1463 1464 M-~ 1465 change-case 1466 1467 1468 M-. 1469 vi-repeat-change 1470 1471 1472 M-% 1473 find-parenthesis 1474 1475 1476 M-a 1477 vi-append 1478 1479 1480 M-A 1481 vi-append-at-eol 1482 1483 1484 M-b 1485 backward-word 1486 1487 1488 M-B 1489 backward-word 1490 1491 1492 M-C 1493 vi-change-rest-of-line 1494 1495 1496 M-cb 1497 vi-backward-change-word 1498 1499 1500 M-cB 1501 vi-backward-change-word 1502 1503 1504 M-cc 1505 vi-change-line 1506 1507 1508 M-ce 1509 vi-forward-change-word 1510 1511 1512 M-cE 1513 vi-forward-change-word 1514 1515 1516 M-cw 1517 vi-forward-change-word 1518 1519 1520 M-cW 1521 vi-forward-change-word 1522 1523 1524 M-cF 1525 vi-backward-change-find 1526 1527 1528 M-cf 1529 vi-forward-change-find 1530 1531 1532 M-cT 1533 vi-backward-change-to 1534 1535 1536 M-ct 1537 vi-forward-change-to 1538 1539 1540 M-c; 1541 vi-change-refind 1542 1543 1544 M-c, 1545 vi-change-invert-refind 1546 1547 1548 M-ch 1549 vi-backward-change-char 1550 1551 1552 M-c^H 1553 vi-backward-change-char 1554 1555 1556 M-c^? 1557 vi-backward-change-char 1558 1559 1560 M-cl 1561 vi-forward-change-char 1562 1563 1564 M-c<space> 1565 vi-forward-change-char (META-c-space) 1566 1567 1568 M-c^ 1569 vi-change-to-bol 1570 1571 1572 M-c0 1573 vi-change-to-bol 1574 1575 1576 M-c$ 1577 vi-change-rest-of-line 1578 1579 1580 M-c| 1581 vi-change-to-column 1582 1583 1584 M-c% 1585 vi-change-to-parenthesis 1586 1587 1588 M-dh 1589 backward-delete-char 1590 1591 1592 M-d^H 1593 backward-delete-char 1594 1595 1596 M-d^? 1597 backward-delete-char 1598 1599 1600 M-dl 1601 forward-delete-char 1602 1603 1604 M-d<space> 1605 forward-delete-char (META-d-space) 1606 1607 1608 M-dd 1609 delete-line 1610 1611 1612 M-db 1613 backward-delete-word 1614 1615 1616 M-dB 1617 backward-delete-word 1618 1619 1620 M-de 1621 forward-delete-word 1622 1623 1624 M-dE 1625 forward-delete-word 1626 1627 1628 M-dw 1629 forward-delete-word 1630 1631 1632 M-dW 1633 forward-delete-word 1634 1635 1636 M-dF 1637 backward-delete-find 1638 1639 1640 M-df 1641 forward-delete-find 1642 1643 1644 M-dT 1645 backward-delete-to 1646 1647 1648 M-dt 1649 forward-delete-to 1650 1651 1652 M-d; 1653 delete-refind 1654 1655 1656 M-d, 1657 delete-invert-refind 1658 1659 1660 M-d^ 1661 backward-kill-line 1662 1663 1664 M-d0 1665 backward-kill-line 1666 1667 1668 M-d$ 1669 kill-line 1670 1671 1672 M-D 1673 kill-line 1674 1675 1676 M-d| 1677 delete-to-column 1678 1679 1680 M-d% 1681 delete-to-parenthesis 1682 1683 1684 M-e 1685 forward-word 1686 1687 1688 M-E 1689 forward-word 1690 1691 1692 M-f 1693 forward-find-char 1694 1695 1696 M-F 1697 backward-find-char 1698 1699 1700 M-- 1701 up-history 1702 1703 1704 M-h 1705 cursor-left 1706 1707 1708 M-H 1709 beginning-of-history 1710 1711 1712 M-i 1713 vi-insert 1714 1715 1716 M-I 1717 vi-insert-at-bol 1718 1719 1720 M-j 1721 down-history 1722 1723 1724 M-J 1725 history-search-forward 1726 1727 1728 M-k 1729 up-history 1730 1731 1732 M-K 1733 history-search-backward 1734 1735 1736 M-l 1737 cursor-right 1738 1739 1740 M-L 1741 end-of-history 1742 1743 1744 M-n 1745 history-re-search-forward 1746 1747 1748 M-N 1749 history-re-search-backward 1750 1751 1752 M-p 1753 append-yank 1754 1755 1756 M-P 1757 yank 1758 1759 1760 M-r 1761 vi-replace-char 1762 1763 1764 M-R 1765 vi-overwrite 1766 1767 1768 M-s 1769 vi-forward-change-char 1770 1771 1772 M-S 1773 vi-change-line 1774 1775 1776 M-t 1777 forward-to-char 1778 1779 1780 M-T 1781 backward-to-char 1782 1783 1784 M-u 1785 vi-undo 1786 1787 1788 M-w 1789 forward-to-word 1790 1791 1792 M-W 1793 forward-to-word 1794 1795 1796 M-x 1797 forward-delete-char 1798 1799 1800 M-X 1801 backward-delete-char 1802 1803 1804 M-yh 1805 backward-copy-char 1806 1807 1808 M-y^H 1809 backward-copy-char 1810 1811 1812 M-y^? 1813 backward-copy-char 1814 1815 1816 M-yl 1817 forward-copy-char 1818 1819 1820 M-y<space> 1821 forward-copy-char (META-y-space) 1822 1823 1824 M-ye 1825 forward-copy-word 1826 1827 1828 M-yE 1829 forward-copy-word 1830 1831 1832 M-yw 1833 forward-copy-word 1834 1835 1836 M-yW 1837 forward-copy-word 1838 1839 1840 M-yb 1841 backward-copy-word 1842 1843 1844 M-yB 1845 backward-copy-word 1846 1847 1848 M-yf 1849 forward-copy-find 1850 1851 1852 M-yF 1853 backward-copy-find 1854 1855 1856 M-yt 1857 forward-copy-to 1858 1859 1860 M-yT 1861 backward-copy-to 1862 1863 1864 M-y; 1865 copy-refind 1866 1867 1868 M-y, 1869 copy-invert-refind 1870 1871 1872 M-y^ 1873 copy-to-bol 1874 1875 1876 M-y0 1877 copy-to-bol 1878 1879 1880 M-y$ 1881 copy-rest-of-line 1882 1883 1884 M-yy 1885 copy-line 1886 1887 1888 M-Y 1889 copy-line 1890 1891 1892 M-y| 1893 copy-to-column 1894 1895 1896 M-y% 1897 copy-to-parenthesis 1898 1899 1900 M-^E 1901 emacs-mode 1902 1903 1904 M-^H 1905 cursor-left 1906 1907 1908 M-^? 1909 cursor-left 1910 1911 1912 M-^L 1913 clear-screen 1914 1915 1916 M-^N 1917 down-history 1918 1919 1920 M-^P 1921 up-history 1922 1923 1924 M-^R 1925 redisplay 1926 1927 1928 M-^D 1929 list-or-eof 1930 1931 1932 M-^I 1933 complete-word 1934 1935 1936 M-\r 1937 newline 1938 1939 1940 M-\n 1941 newline 1942 1943 1944 M-^X^R 1945 read-init-files 1946 1947 1948 M-^Xh 1949 list-history 1950 1951 1952 M-0, M-1, ... M-9 1953 digit-argument (see below) 1954 1955 1956 1957 Note that ^I is what the TAB key generates. 1958 1959 Entering Repeat Counts 1960 Many of the key binding functions described previously, take an 1961 optional count, typed in before the target key sequence. This is 1962 interpreted as a repeat count by most bindings. A notable exception is 1963 the goto-column binding, which interprets the count as a column number. 1964 1965 1966 By default you can specify this count argument by pressing the META key 1967 while typing in the numeric count. This relies on the digit-argument 1968 action being bound to 'META-0', 'META-1' etc. Once any one of these 1969 bindings has been activated, you can optionally take your finger off 1970 the META key to type in the rest of the number, since every numeric 1971 digit thereafter is treated as part of the number, unless it is 1972 preceded by the literal-next binding. As soon as a non-digit, or 1973 literal digit key is pressed the repeat count is terminated and either 1974 causes the just typed character to be added to the line that many 1975 times, or causes the next key binding function to be given that 1976 argument. 1977 1978 1979 For example, in emacs mode, typing: 1980 1981 M-12a 1982 1983 1984 1985 causes the letter 'a' to be added to the line 12 times, whereas 1986 1987 M-4M-c 1988 1989 1990 1991 Capitalizes the next 4 words. 1992 1993 1994 In vi command mode the meta modifier is automatically added to all 1995 characters typed in, so to enter a count in vi command-mode, just 1996 involves typing in the number, just as it does in the vi editor itself. 1997 So for example, in vi command mode, typing: 1998 1999 4w2x 2000 2001 2002 2003 moves the cursor four words to the right, then deletes two characters. 2004 2005 2006 You can also bind digit-argument to other key sequences. If these end 2007 in a numeric digit, that digit gets appended to the current repeat 2008 count. If it doesn't end in a numeric digit, a new repeat count is 2009 started with a value of zero, and can be completed by typing in the 2010 number, after letting go of the key which triggered the digit-argument 2011 action. 2012 2013 FILES 2014 /usr/lib/libtecla.so 2015 The tecla library 2016 2017 2018 /usr/include/libtecla.h 2019 The tecla header file 2020 2021 2022 ~/.teclarc 2023 The personal tecla customization file 2024 2025 2026 ATTRIBUTES 2027 See attributes(5) for descriptions of the following attributes: 2028 2029 2030 2031 2032 +--------------------+-----------------+ 2033 | ATTRIBUTE TYPE | ATTRIBUTE VALUE | 2034 +--------------------+-----------------+ 2035 |Interface Stability | Evolving | 2036 +--------------------+-----------------+ 2037 2038 SEE ALSO 2039 vi(1), cpl_complete_word(3TECLA), ef_expand_file(3TECLA), 2040 gl_get_line(3TECLA), gl_io_mode(3TECLA), libtecla(3LIB), 2041 pca_lookup_file(3TECLA), attributes(5) 2042 2043 2044 2045 April 9, 2016 TECLA(5)