vi: Line too long

橙三吉。 提交于 2019-12-19 17:34:06

问题


When I use vi to analyze log files, it sometimes is stuck with the error: 'Line too long'. I can watch the file using more, but that's not what I want.

The command view leads to the same result and less is not installed.

System is HP-UX v B.11.31 U ia64

  1. What does this error mean? Does vi really have a limitation on how many characters per line is allowed?
  2. Is there a workaround how to get the files open and displayed in vi anyway?

回答1:


(1) Apparently so :-)

I've never run into a limitation in vim (a) before but it may be that the vi shipping with HPUX is not vim.

(2) What sort of analysis are you doing on log files with vi?

This is the sort of task perfectly suited to text processing tools like sed, awk and Perl, in order of increasing awesomeness.


(a): You may want to consider grabbing vim if you don't have it already. From the vi_diff part of the documentation (differences between vi and vim):

Vim has only a few limits for the files that can be edited {Vi: can not handle characters and characters above 128, has limited line length, many other limits}.

Maximum line length: On machines with 16-bit ints (Amiga and MS-DOS real mode): 32767, otherwise 2147483647 characters. Longer lines are split.

Maximum number of lines: 2147483647 lines.

Maximum file size: 2147483647 bytes (2 Gbyte) when a long integer is 32 bits. Much more for 64 bit longs. Also limited by available disk space for the swap-file.




回答2:


Find out the limit supported, then use fold

fold -80 your_file | more

Or

fold -80 your_file > /tmp/your_file.0
vim /tmp/your_file.0


来源:https://stackoverflow.com/questions/12276317/vi-line-too-long

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!