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 don’t 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 without any file
#vi


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.
a.cat 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:-)