Hacker News new | ask | show | jobs
by jolmg 2250 days ago
> The only feature I miss from all other editors is the incredible speed of Sublime Text: to this day, if I ever have to edit an SQL dump (which I hope I will never ever have to do again), I'm surely reaching for Sublime Text, no other editor can AFAIK open a 200+MB file without freezing and/or crashing.

I just tried opening a 1.1GB SQL dump in vim. It took 11 seconds or so to open. That was pretty slow, but after it opened, it was pretty fluid. I could jump to the end or the middle of the file in an instant and move around like it was nothing.

EDIT: I just grew it to 10GB, and though it took longer to open, vim still works fluidly after it does. Saving the file does take about a minute or two, though.

I was surprised to find that ex wasn't able to open the 1.1GB file. It returns an error actually saying that the file is too large. Since feedback is very minimal, I would have expected it to work by loading the file incrementally in a small buffer like less does without even worrying about the whole thing at the start (no displaying total number of lines, etc.).

ed was able to open the 1.1GB file, but not the 10G one. It returns an error saying that there is no space left on device. I imagine it refers to RAM. That's pretty disappointing.

2 comments

> Saving the file does take about a minute or two, though.

Last time I strace-ed vim, it did a ftruncate to 0 on the original file before writing the whole content back; so no suprise it's rather slow if it dumps 10GB on disk :)

Yeah, I wasn't expecting it not to write the whole 10GB. I don't think optimizing to write just the changes is worth it. Probably no editor has done something like that. I mean if the user inserts or deletes near the beginning of the file, there's no other choice but to write the whole thing to shift the content, anyways. It's just not worth the additional complexity to minimize the writes.
I think ed uses a tmp file.

You can try a custom sam(1) fork (it uses structural regex, google/ddg them): https://github.com/deadpixi/sam

sam -d for the classic cli mode.

Yeah, ex too. I didn't know sam had a cli mode. Unfortunately, the one I have installed from[1] coredumps with the 1.1GB file after trying to write to a temp file.

[1] https://swtch.com/plan9port/

That's the plan9 port edition, maybe the forked one works better. Use "sam -d" for the cli version. You won't miss a lot in the end.