How To Open Big Size File Using VI Editor?


How to Open/edit large files using VI?
Ans : Some time you will get message like file is too large to open with VI editor or some sort of other error messages like. 

For Example : Warning: Tmp file too large

This doesn't mean that you don't have enough space to open the file in /var/tmp (this is default VI editor temp location). This is because VI is having limitation in opening big files which is more than 9070000 character or file of size 2GB.
This is a warning message you get from vi (i.e. the ex family of editors) that it can not track your changes in the temporary files, the editor maintains during an edit session. So when ever using VI editor remember following things(These are from VI editor manual).

1.If the editor crashes (i.e. system halts, or accidental process termination), a preserve file cannot be created and you will not be able to recover your changes via the recover feature(vi -r filename is used to recover a file from .swp file).

2.In addition, while editing a very large files and vi fails to come up in visual mode, do not write this file (:w) since it may be truncated/crashed. You should quit (:q!) and open the file with csplit utility to divide the big file into smaller smaller files and edit(I dont suggest this as it is very much advanced to normal users).

3.To open files less than 2GB use following procedure
Step1 : Just execute vi command with out any file

Step2 :
In the command mode,
type :set directory="any directory with enough free space"

Step3 :
Now open the file using
:e "file name"
And start editing it. Once you are done you can save and exit(:wq).

Through this way we can avaoid vi crashing.
Some utilities which is used to view large files are. filename more
b.tail filename

c.head filename
d.more filename
e.less filename

To open a file at desired line
head -n filname tail -1

Please comment your thoughts regarding this post:-)

  • Like the post? Please Subscribe to free RSS feed to get updates
  • Archive

    Translate this page


    The Linux Juggernaut | Copyright 2006-2009 Surendra Kumar Anne | Surendra's Home Page | Give us feedback how we are doing, Click here