Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I've got a fairly simple problem here: I have a piece of text which is one giant big line (~150,000 characters). No line breaks, and it's a fixed-length flat file (i.e. it was produced by a COBOL program), so introducing line breaks is not only awkward, it's actively unhelpful if I'm trying to make changes to the file.

Most text editors struggle with a single line that big (less doesn't like it, Gedit doesn't like it, nano doesn't like it, I've heard vim doesn't like it, etc), though they do work.

Does anyone have any suggestions for an editor that would be better suited to the data I'm working with? It's only a single line, but it still causes more problems than a 1GiB+ text file with normal-length lines would...

Would be even better if it would work with EBCDIC and not barf when it encounters null bytes, or mangle them when writing back out (some fields are binary-encoded decimals).

Please note, this isn't about files that are big in terms of raw size - the file contains only a single line - but about the fact that most editors aren't optimized to cope with very long lines.

share|improve this question

closed as off-topic by random Jul 7 at 17:45

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions seeking product, service, or learning material recommendations are off-topic because they become outdated quickly and attract opinion-based answers. Instead, describe your situation and the specific problem you're trying to solve. Share your research. Here are a few suggestions on how to properly ask this type of question." – random
If this question can be reworded to fit the rules in the help center, please edit the question.

1  
@smc see his last paragraph where he says this isn't about big in terms of raw size –  barlop Jul 7 at 12:19
    
Perhaps you could show a screenshot of how the obvious things to try - vim/gvim or emacs fails (if they do!)? –  barlop Jul 7 at 12:20
    
@barlop (+1), you are correct, I have removed my comment –  smc Jul 7 at 12:22
    
@barlop They don't fail in the sense of not working, they just tend to be really slow. I've also pasted long lines into Eclipse once or twice, and that was a really bad idea - completely locked it up, actually had to kill the process. –  ipsi Jul 7 at 12:40
2  
Have you just tried vim? You heard it's going to be slow, but why don't you just give it a try? It won't cost you much. –  Dakatine Jul 7 at 12:52

4 Answers 4

up vote 5 down vote accepted

I think a file like the way you are describing is, for practical purposes, acting like a binary file and you should treat it as such.

You could attack it with a hex editor, but that doesn't help you with the EBCIDC part.

If you have to do a lot of editing on this file and are intimately familiar with its fixed-length record format, it may be worth your time to whip up something in Perl or another language (I suggest Perl because it's old and would very likely have modules that convert UTF-8, etc. to EBCIDC), that would work with this file's specific format.

share|improve this answer

I actually just tried vim on a file with a single line of 150000 characters and it ran smooth as silk.

So I guess you should really give it a go, if you didn't just because you heard vim doesn't like such kind of files.

Here's how I got my file:

seq 150000 | while read num; do echo -n "b" ; done > megaline.txt
share|improve this answer
1  
I've seen Vim handle large files well and I've seen Vim handle large files poorly. It very much depends on the configuration. (My main configuration handles long lines poorly, but it doesn't come up often so I haven't investigated lately) –  RJHunter Jul 7 at 14:02
3  
Turn syntax highlighting off if it runs slowly. –  ultrasawblade Jul 7 at 16:12

I tried the same method as Dakatine with my emacs install and it worked fine. No hangups, nothing. If you're editing plain text (i.e. not doing any of the kind of analysis that a mode for a programming language requires, in text-mode), it's going to be really, really hard to lock up emacs. The behavior that you're seeing with Eclipse is probably a reflection of the fact that Eclipse is trying to do some sort of analysis on the text as it renders it -- ditto for Gedit. I also can't reproduce your issue with less -- it comes out fine for me.

share|improve this answer
    
Plus you've got things like CobolMode and Ebcidic Table that might help. –  jwd630 Jul 7 at 17:44

Give it a try: JEdit - A programmer editor

It's got some advanced buffering features, and highly optimized I/O, but takes a while to start up (due to JVM). I've been using it to view & edit over 1GiB files without any trouble - at least on Debian. I cannot guarantee it will behave as good on windows though... :)

share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.