Working with huge files in VIM -


I tried to open a huge (~ 2GB) file in VIM, but it is suppressed. I do not really need to edit the file, just jump around efficiently.

How can I go about working with huge files in VIM?

Today, I had a 12 GB file to edit. The Vim LargeFile plugin did not work for me. Also uses all of my memory and then prints an error message :-( I can not use hexadec in any form, because it can not contain anything, just overwrites it. This is an alternative approach :

You edit the file, then the parts are not And then reconstruct it. You still need two disk space.

  • Grep for anything around the line that you want to edit Want:

    Remove the category of the
     grep -n 'something' HUGEFILE | head-n 1  
  • Row 4 and 5. Repeat:

      sed -n -e '4,5p' -e '5q' huge file & Gt; SMALLPART  
    • 4,5 p print line
    • / P>
    • Combine the file:

        (head -n 3 HUGEFILE; Cat SMALLPART; Sed -e '1,5d' large fire) & gt; HUGEFILE.new  
      • i.e.: Select all lines before edited lines from HUGEFILE (which are the top 3 rows in this case), combine it with edit lines, this case line 4 and 5) and use this combined set line to replace the equivalent (top 5 lines in this case) in HUGEFILE and write it all in a new file.

      HUGEFILE.new will now have your edited file, you can delete the original HUGEFILE .


Comments

Popular posts from this blog

MySql variables and php -

url rewriting - How to implement the returnurl like SO in PHP? -

Which Python client library should I use for CouchdB? -