Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
TECO (text editor)
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
==Example code== Given a file named hello.c with the following contents: <syntaxhighlight lang="c"> int main(int argc, char **argv) { printf("Hello world!\n"); return 0; } </syntaxhighlight> one could use the following TECO session (noting that the prompt is "*" and "$" is how ESC is echoed) to change "Hello" into "Goodbye": :{| class="wikitable" ! TECO session !! explanation |-- | <code>*EBhello.c$$</code> | Open file for read/write with backup |-- | <code>*P$$</code> | Read in the first page |-- | <code>*SHello$0TT$$</code> | Search for "Hello" and print the line (pointer placed after searched string) printf("Hello world!\n"); The line |-- | <code>*-5DIGoodbye$0TT$$</code> | Delete five characters before pointer (ie "Hello"), insert "Goodbye", and print the line<br> printf("Goodbye world!\n"); The updated line |-- | <code>*EX$$</code> | Copy the remainder of the file and exit |} These two example programs are a simple interchange sort of the current text buffer, based on the 1st character of each line, taken from the PDP-11 TECO User's Guide.<ref name=StdTeco/> A "[[GOTO|goto]]" and "[[structured programming|structured]]" version are shown. The second program originally had a bug that prevented the program terminating and the fixed version is used here instead. ===Example 1=== !START! j 0aua ! jump to beginning, load 1st char in register A ! !CONT! l 0aub ! load first char of next line in register B ! qa-qb"g xa k -l ga 1uz ' ! if A>B, switch lines and set flag in register Z ! qbua ! load B into A ! l z-."g -l @o/CONT/ ' ! loop back if another line in buffer ! qz"g 0uz @o/START/ ' ! repeat if a switch was made on last pass ! ===Example 2=== <0uz ! clear repeat flag ! j 0aua l ! load 1st char into register A ! <0aub ! load 1st char of next line into B ! qa-qb"g xa k -l ga -1uz ' ! if A>B, switch lines and set flag ! qbua ! load B into A ! l .-z;> ! loop back if another line in buffer ! qz;> ! repeat if a switch was made last pass !
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)