Sponsored Content
Full Discussion: Weird behavior of Vi
Top Forums UNIX for Dummies Questions & Answers Weird behavior of Vi Post 302631761 by gary_w on Friday 27th of April 2012 11:25:50 PM
Old 04-28-2012
And now for a trip in the wayback machine.... Regarding the user-friendliness of vi, if you put yourself back in the days when it was written, it was actually very user-friendly, just in different terms then what that means today.

Back in the 70's remote terminals connected to UNIX boxes via phone lines at maybe 300 baud. Can you imagine today writing a program where you type a command, have to wait a sec or 2 to the results, repeat!?

The developers of vi (Bill Joy, etc) made each keystroke count, which meant very short, cryptic commands (that you just plain had to memorize) sure did a lot. You had to minimize that wait time and get the most bang for the keystroke. vi is super-powerful but you just have to learn all those cryptic commands to really be effecient. Why just keep pressing 'l' (that's an ell) to go right when you can press w for word and move faster that direction? Or even better f for find followed by the letter you need to move to? Much quicker once you memorized the movement commands and that is just scratching the surface.

Did you ever wonder why Bill Joy made the left, up, down, right keys h, j, k, l? The first version of vi was developed on the Lear-Siegler ADM-3A, the first terminal with addressable cursor capability which allowed positioning of the cursor at an x,y location on the screen. Before that, text scrolled up just like paper on the teletype machines which preceded the crt tube terminals (still called tty's, short for teletype). Guess which keys had the arrows on them since there were no separate arrow keys yet?

Image Photo from http://www.tentacle.franken.de/adm3a/

And the Tilda (~) was on the "home" button too, which I assume is where we got the ~ as a shortcut for your home directory.

First the curses library was written in C to support the addressable cursor capability, and right after one of the first real games (and still my favorite), Rogue, was developed to test it they wrote the front end to the ex editor, vi (for visual interface).

Here's a great cheat sheet for vi commands: Vi Cheat Sheet There are others out there too.

Anyway, I hope this historical trip down memory lane makes you appreciate your favorite editor even more when put in the context of the era.

Gary

Last edited by gary_w; 05-02-2012 at 11:54 AM.. Reason: fixed typos
This User Gave Thanks to gary_w For This Post:
 

10 More Discussions You Might Find Interesting

1. Solaris

Weird behavior on a Sun Fire V120 running solaris 10.

All, After a power loss I went to power on our sun fire v120 that is running solaris 10 and now it will not boot. I tried power cycling it from the lom and pulling the cord but nothing works. All it does is after a power cycle it will start to boot and then start to spit out a bunch of hex... (2 Replies)
Discussion started by: jsandova
2 Replies

2. Shell Programming and Scripting

weird behavior of grep -P

I met a problem in using grep -P. There is a text file, temp.txt, whose content is: dddd abc I ran the command: grep -P "\s*abc" temp.txt The result I expected is: abc But, the actual result is: dddd abc Could anyone tell me what is wrong? Thanks. (2 Replies)
Discussion started by: pankai
2 Replies

3. OS X (Apple)

Weird rsync behavior

I use rsync to keep a directory in synchronization betwen a Linux box with the hostname brutal and a Mac running OS X 10.5 (Leopard) with the hostname cooper. When I run the following command on my Linux machine: rsync -avz --delete myuserid@cooper:/Library/WebServer/Documents... (2 Replies)
Discussion started by: scotbuff
2 Replies

4. UNIX for Dummies Questions & Answers

Weird Behavior of a Script

ok, there's a script i'm working on written in shell programming. #!/bin/sh this script is written to spit out the contents of certain variables inside of it so the output looks something like this: server01=89 server02=69 server03=89 server04=76 now, when i run this script from the... (4 Replies)
Discussion started by: SkySmart
4 Replies

5. UNIX for Dummies Questions & Answers

Weird home key behavior

Hi there, I'm using putty to connect to several servers. On every remote machine, the home key takes me at the beginning of a command line. Exept on one machine where a press on the home key outputs the tilde sign (~). Is there any place where I can override this behavior, I really prefer my... (6 Replies)
Discussion started by: chebarbudo
6 Replies

6. Shell Programming and Scripting

awk print behavior weird

Hi Experts I am facing a weird issue while using print statement in awk. I have a text file with 3 fields shown below: # cat f1 234,abc,1000 235,efg,2000 236,jih,3000 # When I print the third column alone, I dont face any issue as shown below: # awk '{print $3 }' FS=, f1 1000 2000... (5 Replies)
Discussion started by: guruprasadpr
5 Replies

7. UNIX for Dummies Questions & Answers

Weird behavior of backslash, please help!!

Hi I am getting absurd behavior of escape character in echos as followed:oinlcso003{arsadm} #: echo "\as shdd" \as shdd oinlcso003{arsadm} #: echo "Well, isn't that \"special\"?" Well, isn't that "special"? oinlcso003{arsadm} #: echo "Well, isn't that \special\?" Well, isn't that \special\?... (3 Replies)
Discussion started by: nixhead
3 Replies

8. UNIX and Linux Applications

weird yum behavior with provides and install

Why could whatprovides not lookup this info for over 10 minutes, but install could install that package in less than a minute? $ yum whatprovides */lsb_release Loaded plugins: langpacks, presto, refresh-packagekit, versionlock ^Cupdates/group 18% 3.1 kB/s | 360 kB 08:28 ETA ... (0 Replies)
Discussion started by: cokedude
0 Replies

9. UNIX for Advanced & Expert Users

Weird TR behavior. Replacing two instance

Can someone please explain what's wrong with the command i use below? tr -c '\11\12\40-\176' ' '< $TEMP_FILE > $TEMP_FILE2 The invalid character/s is replaced with two spaces, the string2 only have 1 space in it. Please help. Sample output: 333243,333244c333243,333244 < ... (1 Reply)
Discussion started by: Jin_
1 Replies

10. Shell Programming and Scripting

Commenting out "expr" creates weird behavior

This really puzzles me. The following code gives me the error 'expr: syntax error' when I try to do multi-line comment using here document <<EOF echo "Sum is: `expr $1 + $2`" EOF Even if I explicitly comment out the line containing the expr using "#", the error message would still exist... (3 Replies)
Discussion started by: royalibrahim
3 Replies
tset(1) 						      General Commands Manual							   tset(1)

Name
       tset - set terminal mode

Syntax
       tset [options] [-m[ident] [test baudrate]:type] ... [ type ]
       reset ...

Description
       The  command sets up your terminal when you first log in to a UNIX system.  It does terminal dependent processing such as setting erase and
       kill characters, setting or resetting delays, sending any sequences needed to properly initialized the terminal, and the  like.	 It  first
       determines the type of terminal involved, and then does necessary initializations and mode settings.  The type of terminal attached to each
       UNIX port is specified in the /etc/ttys database.  Type names for terminals may be found in the database.  If a port is	not  wired  perma-
       nently to a specific terminal (not hardwired) it is given an appropriate generic identifier such as dialup.

       In  the	case  where no arguments are specified, simply reads the terminal type out of the environment variable TERM and re-initializes the
       terminal.  The rest of this manual concerns itself with mode and environment initialization, typically done once at login, and options used
       at initialization time to determine the terminal type and set up terminal modes.

       When  used  in a startup script (.profile for users or .login for users) it is desirable to give information about the type of terminal you
       will usually use on ports which are not hardwired.  These ports are identified in as dialup or plugboard or arpanet.  To specify what  ter-
       minal  type  you usually use on these ports, the -m (map) option flag is followed by the appropriate port type identifier, an optional baud
       rate specification, and the terminal type.  (The effect is to ``map'' from some conditions to a terminal type, that is, to tell ``If I'm on
       this  kind  of  port, guess that I'm on that kind of terminal''.)  If more than one mapping is specified, the first applicable mapping pre-
       vails.  A missing port type identifier matches all identifiers.	Any of the alternate generic names given in may be used  for  the  identi-
       fier.

       A  baudrate  is specified as with and is compared with the speed of the diagnostic output (which should be the control terminal).  The baud
       rate test may be any combination of: >, @, <, and !; @ means ``at'' and !  inverts the sense of the test.  To avoid problems with metachar-
       acters,	it  is best to place the entire argument to -m within ``''' characters; users of must also put a ``'' before any ``!'' used here.
       Thus
       tset -m 'dialup>300:adm3a' -m dialup:dw2 -m 'plugboard:?adm3a'

       causes the terminal type to be set to an adm3a if the port in use is a dialup at a speed greater than 300 baud; to a dw2  if  the  port	is
       (otherwise)  a  dialup  (that is, at 300 baud or less).	(The examples given here appear to take up more than one line, for text processing
       reasons.  When you type in real commands, you must enter them entirely on one line.)  If the type finally determined by begins with a ques-
       tion  mark, the user is asked if he really wants that type.  A null response means to use that type; otherwise, another type can be entered
       which is used instead.  Thus, in the above case, the user is queried on a plugboard port as to whether they are actually using an adm3a.

       If no mapping applies and a final type option, not preceded by a -m, is given on the command line then that type  is  used;  otherwise  the
       identifier found in the database is assumed to be the terminal type.  This should always be the case for hardwired ports.

       It  is  usually	desirable  to  return  the  terminal type, as finally determined by and information about the terminal's capabilities to a
       shell's environment.  This can be done using the - option; using the Bourne shell,
       export TERM; TERM=`tset - options...`

       Or using the C shell,
       setenv TERM `tset - options...`

       With it is convenient to make an alias in your .cshrc:
       alias tset 'setenv TERM `tset - !*`'

       Either of these aliases allow the command
       tset 2621

       to be invoked at any time from your login If you are using the Bourne shell, it is not possible to get this aliasing effect  with  a  shell
       script, because shell scripts cannot set the environment of their parent.

       These commands cause to place the name of your terminal in the variable TERM in the environment.  For further information, see

       Once the terminal type is known, engages in terminal driver mode setting.  This normally involves sending an initialization sequence to the
       terminal, setting the single character erase (and optionally the line-kill (full line erase)) characters,  and  setting	special  character
       delays.	Tab and newline expansion are turned off during transmission of the terminal initialization sequence.

       On  terminals  that  can  backspace but not overstrike (such as a CRT), and when the erase character is the default erase character (`#' on
       standard systems), the erase character is changed to BACKSPACE (Control-H).

       If is invoked as it will set cooked and echo modes, turn off cbreak and raw modes, turn on newline translation, and restore special charac-
       ters  to  a  sensible  state before any terminal dependent processing is done.  Any special character that is found to be NULL or ``-1'' is
       reset to its default value.

       This is most useful after a program dies leaving a terminal in a funny state.  You may have to type ``<LF>reset<LF>'' to  get  it  to  work
       since <CR> may not work in this state.  Often none of this will echo.

Options
       -    Name of terminal is output on stndout, captured by the shell, and placed in the environment variable TERM.

       -ec  Uses the specified character as the erase character.  The default is the backspace character on the terminal, usually ^H.  The charac-
	    ter c can either be typed directly, or entered using the hat notation used here.

       -I   Suppresses transmitting terminal initialization strings.

       -kc  Uses the specified character as the kill character.  It is similar to -e but for the line kill character rather than the erase charac-
	    ter;  c  defaults  to ^X (for purely historical reasons).  The kill characters is left alone if -k is not specified.  The hat notation
	    can also be used for this option.

       -n   Initializes the new tty driver, if applicable.  On systems with the Berkeley 4BSD tty driver, specifies that the new tty driver  modes
	    should  be initialized for this terminal.  For a CRT, the CRTERASE and CRTKILL modes are set only if the baud rate is 1200 or greater.
	    See for more detail.

       -Q   Suppresses erase and kill character message.

       -s   Output commands for TERM.  This option can be used with tset -s ...  and is to be preferred to setenv TERM tset - ... because -s  also
	    sets the TERMCAP variable.

       -S   Similar to -s, but outputs 2 strings suitable for use in csh files as follows:
		      set noglob
		      set term=(`tset -S .....`)
		      setenv TERM $term[1]
		      setenv TERMCAP "$term[2]"
		      unset term
		      unset noglob

Restrictions
       For compatibility with earlier versions of a number of flags are accepted whose use is discouraged:

       -d type	 equivalent to -m dialup:type

       -p type	 equivalent to -m plugboard:type

       -a type	 equivalent to -m arpanet:type

       -E c	 Sets the erase character to c only if the terminal can backspace.

       -	 prints the terminal type on the standard output

       -r	 prints the terminal type on the diagnostic output.

Examples
       These  examples all assume the Bourne shell and use the - option.  If you use use one of the variations described above.  Note that a typi-
       cal use of in a .profile or .login will also use the -e and -k options, and often the -n or -Q options as well.	 These	options  have  not
       been  included here to keep the examples small.	(NOTE: some of the examples given here appear to take up more than one line, for text pro-
       cessing reasons.  When you type in real commands, you must enter them entirely on one line.)

       At the moment, you are on a 2621.  This is suitable for typing by hand but not for a .profile, unless you are always on a 2621.
       export TERM; TERM=`tset - 2621`

       You have an h19 at home which you dial up on, but your office terminal is hardwired and known in /etc/ttys.
       export TERM; TERM=`tset - -m dialup:h19`

       You have a switch which connects everything to everything, making it nearly impossible to key on what port you are coming in on.  You use a
       vt100  in your office at 9600 baud, and dial up to switch ports at 1200 baud from home on a 2621.  Sometimes you use someone elses terminal
       at work, so you want it to ask you to make sure what terminal type you have at high speeds, but at 1200 baud you  are  always  on  a  2621.
       Note the placement of the question mark, and the quotes to protect the greater than and question mark from interpretation by the shell.
       export TERM; TERM=`tset - -m 'switch>1200:?vt100' -m
       'switch<=1200:2621'
       All of the above entries will fall back on the terminal type specified in if none of the conditions hold.  The following entry is appropri-
       ate if you always dial up, always at the same baud rate, on many different kinds of terminals.  Your most common terminal is an adm3a.	It
       always asks you what kind of terminal you are on, defaulting to adm3a.
       export TERM; TERM=`tset - .EE

       If the file
       is not properly installed and you want to
       key entirely on the baud rate, the following can be used:
       export TERM; TERM=`tset - -m '>1200:vt100' 2621`

       Here  is a fancy example to illustrate the power of and to hopelessly confuse anyone who has made it this far.  You dial up at 1200 baud or
       less on a concept100, sometimes over switch ports and sometimes over regular dialups.  You use various terminals at speeds higher than 1200
       over switch ports, most often the terminal in your office, which is a vt100.  However, sometimes you log in from the university you used to
       go to, over the ARPANET; in this case you are on an ALTO emulating a dm2500.  You also often log in on various hardwired ports, such as the
       console,  all of which are properly entered in You want your erase character set to control H, your kill character set to control U, and do
       not want to print the ``Erase set to Backspace, Kill set to Control U'' message.
       export TERM; TERM=`tset -e -k^U -Q - -m
       'switch<=1200:concept100' -m 'switch:?vt100' -m
       dialup:concept100 -m arpanet:dm2500`

Files
       port name to terminal type mapping database

       terminal capability database

See Also
       csh(1), sh(1), stty(1), termcap(5), ttys(5), environ(7)

																	   tset(1)
All times are GMT -4. The time now is 06:10 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy