Tuesday, July 22, 2008

Less? More? Vim

When viewing large files, people typically tend to use a pager program such as more or preferably less. Neither of these buffers the entire file into memory, so it's quick to open a large file and scroll around. If you're using more, you should try less. It lets you scroll backwards in the file as well as forwards.

Out of the box, Vim doesn't do so great for really big files. Features like syntax highlighting and undo history can really slow things down on huge buffers; however, there is a plugin that can ease the pain. The LargeFile plugin is available here, and it really does seem to speed up opening and moving around in files larger than a few megs. A word of caution though, if you're dealing with really huge files, a pager program is still the way to go due to the sheer amount of memory required to manipulate those files.


Anonymous said...

As an alternative to less and more I would highly recommend most : http://www.jedsoft.org/most/index.html

I use most most of the time and vim when I need more powerness.

Some features of most :
- Colors for man pages
- scroll down, up, left right
- wrap / unwrap mode
- bookmarks
- several windows
- tail -f mode
- ...

It is far more feature rich than more and less and still as simple as a pager should be !

Amber said...

Even cooler:

jsut use less (alias less=less -SR for ansi coloring goodness) and if you feel you had really wanted to edit it instead (or want to use a vim feature), hit 'v' and voila you're in vim

of course this is assuming that you won't be teleported to emacs or nano instead :)