WANTED: File scroller similar to less but with more features

Blair P. Houghton bhoughto at pima.intel.com
Thu Feb 21 13:19:03 AEST 1991


In article <15904.27c2939a at levels.sait.edu.au> magrw at levels.sait.edu.au writes:
>        (1)     CASE-INSENSITIVE string search
>        (2)     Intelligent usage of VT100 (and/or VT220) keys such as:
>                        (i)     Cursor keys for moving around the file
>                        (ii)    PrevScrn (instead of b)
>                        (iii)   NextScrn (instead of space bar)
>I need this to run on both a Sun SPARCserver 490 as well as a DECstation 5000
>(running Ultrix).

Off the top of my head:

Try using vi(1), calling it with the name 'view' so it's
automatically read-only.  It automatically handles (i).

Use the following in your setup to take care of (1), (ii) and (iii)
(^F is ctrl-F, which you can get into a file by typing ^V^F
and similarly for ^B and ^M):

	:set ic
	map [6~ ^F
	map [5~ ^B
	map q :q!^M
	map N :n

add these if you still want to use b, f, and the space-bar

	map f ^F
	map b ^B
	map ^V  ^F	(ctrl-V ctrl-V space space ctrl-V ctrl-F)

The setup should appear in a .exrc file, or in your EXINIT
environment variable as

	set ic|map [6~ ^F|map [5~ ^B|map q :q!^M|map N :n

If you want to hide all this and still use your
.exrc for vi(1), alias 'less' and 'vi' as follows
(put the following line in a file and source the file
to set it, or put it in your .cshrc; csh(1) gets confused
by the ^M -- which is a ctrl-M, not an upcaret and an M --
when it sees it on the command-line.):

  alias less 'setenv EXINIT "set ic|map [6~ ^F|map [5~ ^B|map q :q\\!^M";view'
  alias vi 'unsetenv EXINIT; vi'

to use .exrc, or

  alias vi 'setenv EXINIT ...; vi'

where ... is your usual EXINIT, if you prefer EXINIT over .exrc.

You can't pipe to them, but less(1) has its problems with
stdin, too, so you shouldn't pipe to it without some
restrictive suppositions about your file, either.

You also lose some things like flipping back and forth
between files using N and B. (N is easy; B is a pain to
deal with in vi(1)).

But you gain, since you're in the editor, if you want
to make a change.  Just use :unmap to turn off some
of these things (editing would be a mess if you didn't)
and use :w! to write the changes.

				--Blair
				  "Yeh.  Like I'd want to start
				   Emacs every time I wanted to
				   flip through the funnies..."



More information about the Comp.unix.misc mailing list