keybindings

Binding keys

/Def -b allows you to bind a key string to a macro. Typing that string at the keyboard will then call the macro.

/Def -B allows you to bind a symbolic keyname to a macro. There are several advantages in using symbolic key names over key code strings. First, you don't have to know what string is generated by the special keys on your keyboard. They will work on any terminal, based on the value of %TERM (assuming the keys are defined in the termcap database). Changing %TERM at any time will rebind the macros to the new codes.

The keynames recognized by tf are:

Of course, not all terminals have all those keys, and not all termcap entries define every key that the terminal has. The arrow and function are pretty reliably defined, but many of the other keys are less so. Also, terminal emulators often do not match all the key definitions.

They must be spelled as shown, but capitilization is ignored. The function keycode() can be used to find the string generated by a key (as defined in termcap).

Note that before version 3.5 alpha 21 or beta 1, it was usually harmless to "/set TERM=vt100" on terminals that accepted a superset of vt100 display codes. However, the termcap key definitions are often different for terminals that are otherwise similar (e.g., vt100 and xterm share many display codes, but the key definitions are different), so setting %TERM incorrectly will interfere with the operation of named keys. Xterm users should also note that since 3.5 alpha 17, tf ignores xterm's ti and te capabilities that sometimes interfered with the operation of the scrollbar, so tricking tf with TERM=vt100 is no longer necessary.

Special keys

TF's input handler recognizes ^H and ^? as backspace and ^J and ^M as newline, even when they are not bound to macros. However, if a keybinding is defined for any of these keys, it will override the internal handling of that key.

At startup, tf also examines the terminal driver settings for keys corresponding to the /dokey functions BWORD, DLINE, REFRESH, and LNEXT, and binds them accordingly if different than the default bindings listed below.

Default keybindings

Named keys
Key	Command			Meaning
---	-------			-------
Up	/dokey UP		cursor up
Down	/dokey DOWN		cursor down
Right	/dokey RIGHT		cursor right
Left	/dokey LEFT		cursor left
F1	/help			help
Insert	/test insert:=!insert	toggle insert mode
Home	/dokey_home		cursor to beginning of line
PgDn	/dokey page		scroll 1 screenful at --More-- prompt

Unnamed key sequences

String	Command			Meaning
------	-------			-------
^A	/dokey_home		cursor to beginning of line
^B	/dokey_wleft		cursor to beginning of word
^D	/dokey_dch		delete character
^E	/dokey_end		cursor to end of line
^F	/dokey_wright		cursor to end of word
^G	/beep 1			beep
^I	/dokey page		scroll 1 screenful at --More-- prompt
^J	/dokey NEWLINE		execute current line
^K	/dokey_deol		delete to end of line
^L	/dokey redraw		redraw screen
^M	/dokey NEWLINE		execute current line
^N	/dokey recallf		recall forward input history
^P	/dokey recallb		recall backward input history
^R	/dokey REFRESH		refresh line
^T	/kb_transpose_chars	transpose characters
^U	/dokey DLINE		delete line
^V	/dokey LNEXT		input next key literally
^W	/dokey BWORD		delete backward word (space-delimited)
^[^E	/kb_expand_line		expand current line in place
^[spc	/kb_collapse_space	change multiple spaces to a single space
^[-	/kb_goto_match		move cursor to matching parenthesis or bracket
^[.	/kb_last_argument	input last word of previous line
^[J	/dokey selflush		selective flush (flush non-hilited text)
^[_	/kb_last_argument	input last word of previous line
^[b	/fg -<			foreground previous socket
^[c	/kb_capitalize_word	capitalize word
^[d	/dokey_dword		delete forward word
^[f	/fg ->			foreground next socket
^[h	/dokey hpage		scroll half screenful at --More-- prompt
^[j	/dokey flush		flush (discard text after --More-- prompt)
^[l	/kb_downcase_word	downcase word
^[n	/dokey searchf		search forward input history
^[p	/dokey searchb		search backward input history
^[u	/kb_upcase_word		upcase word
^[v	/test insert:=!insert	toggle insert mode
^[^?	/kb_backward_kill_word	delete backward word (punctuation-delimited)

Other key bindings

Some additional keyboard operations can be defined by /loading these library files:
kb-bash.tf
keybindings like those in bash
kb-emacs.tf
keybindings like those in emacs
kbregion.tf
cut-and-paste operations
kbstack.tf
save the current line and recall it later
See the comments at the top of each file for further documentation.

See: /dokey, /bind, completion, %wordpunct


Back to index
Back to tf home page
Copyright © 1995, 1996, 1997 Ken Keys