Operating System - HP-UX
1823736 Members
2530 Online
109664 Solutions
New Discussion юеВ

vi file error: Line too long

 
SOLVED
Go to solution
inventsekar_1
Respected Contributor

vi file error: Line too long

Admins,
when i try to vi a file, i got "line too long"
error.
in man page, i found:
--------------------
Maximum Line Length
4096 characters including 2-3 bytes for overhead. Thus, a line length
up to 4092 characters should cause no problem.

If you load a file that contain lines longer than the specified limit,
the lines are truncated to the stated maximum length. Saving the file
will write the truncated version over the original file, thus
overwriting the original lines completely.

Attempting to create lines longer than the allowable maximum for the
editor produces a line too long error message.

whether i missed something, i dont know..
searched in itrc and no results..

ideas?
Be Tomorrow, Today.
9 REPLIES 9
Peter Godron
Honored Contributor
Solution

Re: vi file error: Line too long

Hi,
if you have to edit a line that big, you may be better off with vim (http://www.vim.org/about.php)


If you just want to read the file:
more filename
vi -R filename

Or you can 'chop up' the file with split and then reassemble with fold.
spex
Honored Contributor

Re: vi file error: Line too long

sekar,

If you need to edit interactively, you could use another editor, such as vim, emacs, or nano. If not, you could stream edit with sed, awk, or perl. Or insert newline characters at a specific column position to bring the overall length under the limit, edit with vi, and then remove the newly-inserted newlines.

PCS
spex
Honored Contributor

Re: vi file error: Line too long

'cut' and 'paste' would be another option.
Dave La Mar
Honored Contributor

Re: vi file error: Line too long

Sekar -
In our shop we tend to avoid creating data as you describe for obvious reasons. When unavoidable, and the need to edit arises, the easiest solution for our developers was using UltaEdit.

I know there are a number of other solutions to your issue, unfortunately I do not have other answers.

Best of luck on this.

Regards,

-dl
"I'm not dumb. I just have a command of thoroughly useless information."
Bill Hassell
Honored Contributor

Re: vi file error: Line too long

"line too long" means that vi encountered a stream of data without a linefeed (LF) character for at least 4092 characters. This is exactly what you would expect if you try to edit a binary file like an executable program. If this is a binary data file, vi would useless as you would need hex or octal codes to modify the lines.

Now if the file really is an ASCII file, and you know that it has extremely long lines, vi is not the right tool. Managing data of that size with a simple editor is not practical. Your application probably needs refining to handle the editing.


Bill Hassell, sysadmin
Yang Qin_1
Honored Contributor

Re: vi file error: Line too long

Check the type of your file with "file filename" and see if it is an ASCII file or not. If you cannot edit it with vi, try to use "more", "tail", "cat" to list the content of that file and see if there is something abnormal.
Sandman!
Honored Contributor

Re: vi file error: Line too long

Depends on what you're trying to do with that file...view it or edit it. You might be better of using ex,sed,or perl if you need to make editing changes or using one of the pagers if you need to view it.

~cheers
Steve Post
Trusted Contributor

Re: vi file error: Line too long

Are you vi-ing the file to see in it? work with a copy of the file.

1. cat myfile | sed G | adjust > myfile2
This MIGHT make the line length short enough.

2. Another option would be to use the dd command. I would give the syntax. But I don't remember if you "block" or "unblock" to 80 characters. Oh here's the syntax anyway....

dd if=./myfile of=./myfile2 conv=block cbs=80

Now try to vi file myfile2.

steve
inventsekar_1
Respected Contributor

Re: vi file error: Line too long

i am trying to "vi filename" and edit that too long line.
i will update u little later..
thanks for the response.
Be Tomorrow, Today.