78

Does anyone have any recommendations for a programmer's editor that can cope with large files on Mac OS X? By large I mean hundreds of megabytes. TextMate doesn't cut it.

Jorge Israel Peña
  • 36,800
  • 16
  • 93
  • 123
John Topley
  • 113,588
  • 46
  • 195
  • 237
  • 4
    Do you need interactive editing? Since a file that large will sort of exceed what a person's brain can handle, perhaps you could just pull chunks out of it and deal with those? Or use sed/perl/python/whatever to apply appropriate changes to a stream, and then feed the file in? – Jay Kominek Jun 04 '09 at 20:28
  • 1
    That's a very good point. It's actually an XML file and I just want to get an idea of its structure. – John Topley Jun 04 '09 at 20:42
  • Vim also does folding in many languages, not sure if it supports XML though. Something to look into :-) – Topher Fangio Jun 05 '09 at 13:53
  • I used the XCode and it really open a 250mb easily :D – Rodrigo Jan 18 '15 at 17:20
  • 4
    >5gb log file on a Haswell Core i7 iMac with 16GB and an SSD running Mavericks: **TextMate:** opens an empty, one-line file with the right name and then sits there doing nothing. I waited close to an hour before bailing on it. **TextWrangler & BBEdit:** error immediately. **Sublime Text 2:** progress bar for 9 minutes, then spinning wheel for two more, then perfect **Console:** only 16MB chunks at a time. Can't view, scroll, or search the entire file at once. – JakeRobb Apr 28 '15 at 15:03
  • 5
    **Crisp:** makes me register before I can download the trial. Booooo. Did not evaluate. **XCode:** spinning wheel for five minutes; scrolling is fine, but editing and searching are terrible. **MacVim:** opens a blank, white window. no spinning wheel. 30 seconds later, file is open. Searching, editing, and scrolling are all excellent. **Verdict:** Depending on your priorities, I give the win to Sublime Text 2 or MacVim. – JakeRobb Apr 28 '15 at 15:03
  • Thanks [Crisp](https://stackoverflow.com/users/535401/jakerobb) for taking the time of testing with those software clients – d1jhoni1b Aug 13 '18 at 18:24
  • This question on Ask Different (where it isn't closed): https://apple.stackexchange.com/questions/3437/whats-the-best-text-editor-for-use-with-large-files – Jon Schneider Dec 17 '19 at 14:56

13 Answers13

68

Have you tried Vim? It's the only editor I use :-)

Edit: It seems to depend upon a couple of factors. I used Vim with large CSV (i.e. text-based) files and that worked great. YMMV :-)

Topher Fangio
  • 20,372
  • 15
  • 61
  • 94
  • 4
    If Vim can truly handle a file hundreds of megabytes in size, I tip my hat to it. I know emacs chokes on enormously large files. – Adam Rosenfield Jun 04 '09 at 20:29
  • I use it on very large log files quite often. It only loads what it needs to. Now, doing some fun data manipulation on every line may take a while ;-) – Topher Fangio Jun 04 '09 at 20:31
  • Yes it can and search and replace is amazingly fast. – Ludwig Weinzierl Jun 04 '09 at 20:44
  • 5
    Vim worked like a charm for me so thanks for the suggestion. BBEdit was choking on only a 78 MB file and VIM opened it in seconds :) –  Oct 27 '09 at 15:38
  • 1
    FWIW I just opened a 4GB SQL dump file in vim on my MacBook Pro. It took a minute to open, but it works... – gtd May 07 '10 at 18:55
  • I like vim, but not for this task. I want my xml editor to be able to collapse and expand xml nodes. That is a big plus. Upvotes here are very confusing to everybody. – hrishikeshp19 Nov 14 '12 at 23:22
  • @hrishikeshp19 Vim actually has support for code folding. Checkout this SO question for more info: http://stackoverflow.com/questions/4789605/how-do-i-enable-automatic-folds-in-vim – Topher Fangio Nov 19 '12 at 01:29
  • 1
    Just a comment- Huge VIM fan but tried to open a 3 GB file on both my Mac (MacVim) and on ubuntu using standard VIM and it is taking a very long time! – SilentSteel Nov 03 '14 at 15:16
  • @SilentSteel - I honestly have seen the problem on newer versions of Vim; the old versions seemed to handle large files much better. I'm not sure if something changed or if we're just opening larger files these days... – Topher Fangio Nov 03 '14 at 20:15
  • Yeah--trying to open a 458MiB JSON file on vim on 10.12.x ... 30 minutes later, still isn't open. – David Beveridge Dec 30 '16 at 20:48
  • Is this still the best tool for such a task, in 2017? – Anupam Jun 09 '17 at 10:20
  • @Anupam Why not? Vim is a great tool and it handles large files well. – Igor Oct 05 '17 at 17:05
  • I just tried VIM to open a 30GB file and it did not work. It just sat there. – dustbuster Oct 09 '18 at 12:17
31

If, as you say, only really need to get an idea of the structure try opening the document in Console. Believe it or not, I'm able to view files as large as 15GB (MAC OSX 10.7.2)

Brandon Berry
  • 327
  • 3
  • 3
27

HexFiend is designed to read files of any size, but you'll need to work using fixed-column character wrapping and no newline detection.

Draxillion
  • 578
  • 3
  • 6
  • 4
    HexFiend is easily one of the fastest to *read* such a file as far as I've seen (5gb sql dump file opened in 3 seconds), but it's not really meant for *editing*. Or, the menus don't seem to imply it. Unless you know otherwise? – Groxx Sep 10 '12 at 17:07
  • This worked for me - Even after Vim failed. – Blair Jan 17 '18 at 00:05
  • HexFiend opened up a 6gb json file in 1-2 seconds, without breaking a sweat – diek May 08 '18 at 21:15
  • cannot handle UTF-8... https://github.com/ridiculousfish/HexFiend/issues/247 – PatrickT Jun 17 '20 at 03:28
18

If you just want to have an idea of structure, how about browsing with more or less?

MikeJ
  • 542
  • 6
  • 19
11

Definitely vim is the answer. Check out the macvim, the mac version.

Xavier Guardiola
  • 2,699
  • 3
  • 19
  • 11
  • Could you explain how vim works? For me it only shows the top or the bottom of the file and does not respond to moving arrows up and down nor to clicking... – PatrickT Jun 17 '20 at 03:21
7

BBEdit, that old standby, is famous for handling really large files with aplomb (or, at least, it was back in the pre-TextMate era). There's a free version, TextWranger; I assume it's based on the same core and should still work.

jacobian
  • 4,648
  • 3
  • 19
  • 11
  • 3
    I tried TextWrangler and it choked on the file unfortunately. – John Topley Jun 04 '09 at 20:47
  • 1
    The latest BBEdit crashed on my 4GB file. I do typically use it for hundred-meg files, but it can't handle GB size files apparently. – gtd May 07 '10 at 18:56
  • 4
    TextWrangler and BBEdit can edit any file up to 384MB. This limit is because they store the entire file in RAM, and it's unicode encrypted so it's not very efficient. I recently used `split -b 300m foo.xml` on a huge XML file, and TextWrangler took several seconds to open it, but then was fully functional - even syntax highlighting. – Abhi Beckert Jun 24 '11 at 09:53
  • 3
    @AbhiBeckert encoded, you meant to say encoded – jcollum Nov 08 '12 at 22:41
4

I have used gvim for files larger than 1 GB of NASTRAN output. gvim handles large files very well. In fact that was the main reason I switched from Emacs to vim.

Emacs is a great editor but it can handle files only as large as 128 MB, at least the 32-bit version. If you decide to use Emacs I recommend to configure it to turn syntax highlighting off for large files.

Another way to deal with large files those days was heavy usage of head, tail and split.

Ludwig Weinzierl
  • 15,980
  • 10
  • 45
  • 49
3

Vim has already been recommended. If you're using vim you might want to also use the LargeFile plugin (by the inimitable Charles "Dr Chip" Campbell), which automatically disables various features of vim in the interests of speed for files over 100Mb (at the default setting).

Michael Dunn
  • 8,163
  • 4
  • 37
  • 54
3

The native emacs on OS X seems to be the 64-bit version now. It works like a charm on my 250MB text file.

andebauchery
  • 956
  • 7
  • 6
1

Since you noted in a comment that it's actually an XML file and you just want to get an idea of its structure, you may want to check out Oxygen's LargeFileViewer, a helper app which is bundled with Oxygen XML Editor. (It might also come with Author, I don't know.)

Avi Flax
  • 50,872
  • 9
  • 47
  • 64
1

emacs, naturally, at least a 64 bit build (you can do that on OS X now, right?)

But also, these are surely generated files. Do you really need to interact with them all at once?

simon
  • 7,044
  • 2
  • 28
  • 30
-2

Crisp claims the ability to edit files of "8GB or more", but I haven't tried it.

Alex Martelli
  • 854,459
  • 170
  • 1,222
  • 1,395
-3

Edit: Do not use Sublime Text 2! Although it worked for me, apparently for many other users Sublime Text 2 can't handle large text files. Below is my original answer:


Sublime Text 2 for Mac 10.6.8 opened up a 200 MB file for me without any problem

gardenofwine
  • 1,344
  • 2
  • 15
  • 24
  • 9
    Just tried it with 180MB SQL file. Opens file for minutes, tries to load whole file to memory. No good – JaakL Aug 28 '12 at 16:06
  • If you are coding 180MB SQL files, I think you are possibly "doing it wrong". (Oh it's an export? well i forgive you then) – unsynchronized Jun 04 '14 at 22:18
  • Sublime Text 3 basically hangs when doing find & replace on large files. – Alex Nov 18 '15 at 11:48
  • Very awesome text editor, but not its strong suit. – indigo Sep 01 '16 at 13:47
  • I keep getting negative feedback on my answer, and I believe all those who downvoted this answer, that my answer was not correct for their use case. Indeed perhaps the only use case my answer was correct is my use case :-). I'm contemplating what to do? should I remove this answer and get some points back to my reputation? I've decided to keep this answer - as a warning to future viewers of this question. DO NOT USE SUBLIME TEXT 2! it appears to not be good for most users. – gardenofwine Apr 28 '17 at 10:24
  • ST is great, but not for opening huge files. e.g.: > 1 GB (though if I recall right even 500 MB is getting annoying, on a 2014 MBP.) – Fabien Snauwaert Jul 06 '17 at 20:13