1833777 Members
2422 Online
110063 Solutions
New Discussion

Re: vi problem

 
Allanm
Super Advisor

vi problem


When opening a file in vi I am able to view close to ~3000 lines even though the file runs 6000 lines. How to resolve this.

Thanks,
Allan
7 REPLIES 7
A. Clay Stephenson
Acclaimed Contributor

Re: vi problem

There are two hard-coded limits at play in vi:

1) Maximum line length - 4096 characters
2) Maximum number of lines - 234239

Are the lines extremely long?

You could also be hitting maxdsiz so chack that setting.

It would help to know what the product of
3000 * line length is.

You can always use split to divide the file into more manageable chucks. Man split for details.
If it ain't broke, I can fix that.
Allanm
Super Advisor

Re: vi problem

Thanks for replying but the lines are not long.
Hein van den Heuvel
Honored Contributor

Re: vi problem

>> When opening a file in vi I am able to view close to ~3000 lines even though the file runs 6000 lines

q1: How do you know you only read about 3000 lines? ^G ?

q2: Is there an error message to share?

What is the output for: wc
What is the output for: ls -l
What is the output for:

$ perl -ne '$l=length; if($l>$m) {$m=$l; $n=$.} }{print qq(Longest=$m at line $n\n)'

hth,
Hein.





A. Clay Stephenson
Acclaimed Contributor

Re: vi problem

I am making the silly assumption that you are trying to read a text file rather rather than a data file which happens to also contain some printable ASCII characters. Vi should have no trouble reading the entire file if it is as you described but I'm betting there is a herd of binary data embedded in your file.

A good technique is to run your file through od (or xd) and then use vi to examine the output.

e.g.
xd -v -Ad -tcxC myfile > mytextfile
vi mytextfile
If it ain't broke, I can fix that.
OldSchool
Honored Contributor

Re: vi problem

another silly assumption: You're not getting the "0 blocks..disk full error"? That'd be too easy
Dennis Handly
Acclaimed Contributor

Re: vi problem

>How to resolve this?

What does vi say when it starts? Does it give the number of lines and chars? Does it match with Hein's wc suggestions?

>Clay: There are two hard-coded limits at play in vi:
>1) Maximum line length - 4096 characters

If so, you need to use vim.

>2) Maximum number of lines - 234239

I have no problems with 303K lines. And even though it says "silently enforced", I'm not sure where I'm losing data? A simple insertion at the start lost nothing.

>Clay: A good technique is to run your file through od (or xd) and then use vi to examine the output.

Using vis(1) and inv(1) would work better if the file is mostly ascii.
Steve Post
Trusted Contributor

Re: vi problem

Do you want to vi the file just to look at it? Use the "more" command.

The file is too big to edit with vi? Make a copy of it smaller but cutting it into pieces. I would do the same thing with a big cookie that is too big to eat.