Korn shell command-line editing

There are two ways of entering either editing mode. First, you can set your editing mode by using the environment variable VISUAL. The Korn shell checks to see if this variable ends with vi or macs. An excellent way to set VISUAL is to put a line like the following in your .profile or environment file:

	VISUAL=$(whence emacs)

or

	VISUAL=$(whence vi)

As you will find out in Chapter 3, Customizing Your Environment and Chapter 4, Basic Shell Programming the whence built-in command takes the name of another command as its argument and writes the command's full pathname on the standard output; the form $(command) returns the standard output generated by command as a string value. Thus, the line above finds out the full pathname of your favorite editor and stores it in the environment variable VISUAL. The advantage of this code is that it is portable to other systems, which may have the executables for editors stored in different directories.

The second way of selecting an editing mode is to set the option explicitly with the set -o command:

	$ set -o emacs

or

	$ set -o vi

You will find that the vi- and emacs-editing modes are good at emulating the basic commands of these editors but not their advanced features; their main purpose is to let you transfer "finger habits" from your favorite editor to the shell. fc is quite a powerful facility; it is mainly meant to supplant C shell history and as an "escape hatch" for users of editors other than vi or emacs. Therefore the section on fc is mainly recommended to C shell users and those who don't use either standard editor.

Comments

Post new comment

The content of this field is kept private and will not be shown publicly.
To prevent automated spam submissions leave this field empty.