Operating System - HP-UX
1752710 Members
6029 Online
108789 Solutions
New Discussion юеВ

Query on using VI and CAT

 
Henry Chua
Super Advisor

Query on using VI and CAT

Hi,

I have some question on the use of VI, when I am using vi as a root and as the general user the number of columns per pages seems to differ, may I know why this is so?

Also if I use a cat and vi to view a file, the special character appears to be different, cat display correctly while vi display a different character. Is there something wrong with the configuration?

Best regards
Henry
5 REPLIES 5
A. Clay Stephenson
Acclaimed Contributor

Re: Query on using VI and CAT

Almost certainly, the TERM setting when you log in as root differs from that when you log in as a regular user. Different TERM setting would account for both of your observed behaviors.
If it ain't broke, I can fix that.
Dennis Handly
Acclaimed Contributor

Re: Query on using VI and CAT

>the special character appears to be different, cat display correctly while vi display a different character.

What is the character? cat(1) won't print unprintable chars depending on the locale.
What is your locale?
Steve Post
Trusted Contributor

Re: Query on using VI and CAT

1. This is probably it.
I have COLUMNS=80 and LINES=24
I bet root has different settings from the other user. It should be set in the user's (or root's) $HOME/.profile.

2. This is what I do when the environment looks different between user A and user B.

I log in as user A.
I run "env > userA.env"
I log in as user B.
I run "env > userB.env"
I log in as either user.
I run "vi /home/userA/userA.env /home/userB/userB.env"
I use :n to move from file userA.env to file userB.env.
I use :rewind to move back to looking at file userA.env.

Or you could just run the diff command on those two files. That seems a lot less complicated.

3. Sometimes there is a .exrc file in the user's home directory. This is a setup file for vi. It has a pile of map commands and set commands in it. Maybe there is a different here. To see all of the set options, go into vi and run ":set all".
I always have: "set showmode noai".
showmode: prints "INPUT MODE" when you are in input mode.
noai: lets me search for text regardless of case. So "/mystuff" and "/mYsTuff" would find the same text.
steve

Dennis Handly
Acclaimed Contributor

Re: Query on using VI and CAT

>Steve: I have COLUMNS=80 and LINES=24

I gave up on those glass terminal dimensions when I got a workstation. I use LINES=36. :-)

The proper way to set the dimensions is:
$ eval $(resize) # for a real shell
Steve Post
Trusted Contributor

Re: Query on using VI and CAT

thanks. I may never get points, but at least I get knowledge.

steve