Editing a huge file - Vim or something else?

8

2

  • I am Vim fan for most of my editing purposes.
  • But these days when I have to open huge file ~1-2 gigs, its is vert slow to load and perform operations
  • What are the other ways I can edit such huge files efficiently

daydreamer

Posted 2011-12-02T18:08:42.703

Reputation: 805

2Turn off syntax can make vim run a little faster. – ajreal – 2011-12-02T18:10:46.453

In my experience loading a big file like that takes some time, but once it is loaded Vim is actually pretty fast. – Brian Rasmussen – 2011-12-02T18:15:13.283

You can always use sed. – None – 2011-12-02T18:43:40.727

Answers

6

Tinyfool

Posted 2011-12-02T18:08:42.703

Reputation: 163

3

Set

:syntax off
:se binary nospell 
:setgl noswap
:set undolevel=0
:set undofile=

You can also use directory/undodir to put swapfiles and undofiles in another location

sehe

Posted 2011-12-02T18:08:42.703

Reputation: 1 796

1

This article explains what you can do to Vim itself to reduce the overhead associated with opening a large file.

MetaEd

Posted 2011-12-02T18:08:42.703

Reputation: 309

1

Look here: https://askubuntu.com/questions/28847/text-editor-to-open-4-3-gb-plain-text-file

  • Divide the file in parts : split -b 53750k <your-file>
  • Edit sigle parts with vim ( I don't like it but it works fast here )
  • Merge the parts cat xa* > <your-file>

Done :)

Sorry but free editor larks good support for big files ( cannot find a reason for that )

p.s.
learn Vim is not so difficult: http://yannesposito.com/Scratch/en/blog/Learn-Vim-Progressively/

Francesco

Posted 2011-12-02T18:08:42.703

Reputation: 209

I had to change the merge command a little bit since I had such a large file that after xaz came xba so xa* would have left out the ones starting with xb. I didn't have any other files starting with x in the same directory so I just used x*. Just in case someone runs into any issues using these commands. – Cvuorinen – 2013-08-07T07:29:36.083

0

See my answer here (not vim specific).

What kind of huge file do you want to edit?

Basile Starynkevitch

Posted 2011-12-02T18:08:42.703

Reputation: 1 022

text file, is that you want to know? – daydreamer – 2011-12-02T18:17:06.867

No, more precisely: a log file, a mysql dump, a big generated assembly code, ...? – Basile Starynkevitch – 2011-12-02T18:18:10.740

a log file is that – daydreamer – 2011-12-02T18:18:28.067

Then my answer applies very well: just csplit your log file into manageable pieces, edit them with your favorite editor, and rebuild the log file. Or develop your own editing scripts (perhaps with sed)... – Basile Starynkevitch – 2011-12-02T18:21:07.213

0

Try joe. I just used it to edit a ~5G SQL dump file. It took about a minute to open the file and a few minutes to save it, with very little use of swap (on a system with 4G RAM).

sierrasdetandil

Posted 2011-12-02T18:08:42.703

Reputation: 125