1834814 Members
2660 Online
110070 Solutions
New Discussion

vi

 
SOLVED
Go to solution
Simon Liu_2
Occasional Contributor

vi

Can I vi or vim a file with more than 80 columns without forcing new line in a 24x80 screen?
5 REPLIES 5
Steven E. Protter
Exalted Contributor

Re: vi

vi isn't going to insert new line characters or anything like that. So yes.

There are limits to how much data it will handle on one line without frying and doing a core dump or somethign.

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
Martin Johnson
Honored Contributor

Re: vi

You will see the line wrap on your 80x24 screen, but there is no newline in the actual file. If you use "$" to get to the end of the line, you see where the actual end of line is. If the line is very long, it may be several lines down on your screen.

HTH
Marty
Simon Liu_2
Occasional Contributor

Re: vi

Sorry for my poor english. What I meant was is there a way that I can view files with straight lines without wrapping. If I vi a file with hundreds of columns for each line, that'll be kind of messing up the screen. I heard vim is improved vi but don't know how to set it up.
harry d brown jr
Honored Contributor

Re: vi

To add to Marty's reply, you can use

:set list

which will display a $ (dollar sign) at the end of each line, plus it will show things like tabs as ^I ....

live free or die
harry
Live Free or Die
Bill Hassell
Honored Contributor
Solution

Re: vi

If you just want to view a file with long lines, you can use cut to limit the view and throw away the extra characters:

cut -c 1-79 /path_to_file/file_name

vi is not messing up the screen, your terminal emulator is providing the line wrap. Most cheap emulators do not have line wrap options. A terminal emulator that allows you to turn off the end-of-line wrap is the WRQ product called Reflection for HP. However, if you turn on this feature, the extra characters beyond the end of the terminal window will simply write over the last character on the line. And in vi, this will be a complex problem for editing. Reflection for HP has an even better feature: you get to define the line length. Instead of 80x24, you can change it to 100x24 or 132x24 or even 200x50. The file will look normal because the width is large enough to display the entire line.

However, if the line width is more than 200 characters, it will be almost impossible to read the tiny characters. In that case, you need to vi and understand that the terminal wil automatically place the long line onto (what appear to be) new lines...they aren't new lines though. vi takes great care to handle long lines in a predictable manner.


Bill Hassell, sysadmin