You can't make
vim behave like
tail -f. You can make
less behave like a combination of
tail -f though.
Forward forever (follow) mode
less has a forward forever mode that you can enter by pressing F or by passing
+F to it as an argument.
$ less +F
In this mode,
less behaves like
tail -f in that it doesn't stop reading when it reaches the end of a file. It constantly refreshes with new data from the file. To exit this mode, press Ctrlc.
less supports automatic filtering of the data it reads. There is a program called source-highlight that can perform basic source code highlighting. It comes with a script that works well with
less. To use it, just set the
LESSOPEN environmental variable appropriately.
export LESSOPEN="| /path/to/src-hilite-lesspipe.sh %s"
You also have to tell
less to pass raw terminal escape sequences (these tell your terminal how to color text) by passing it the
-R flag. You can tell
less to pretend it is always being passed the
-R flag by setting the
LESS environmental variable.
export LESS=' -R '
less isn't enough
less has vi-like keybindings, it just isn't the same as Vim. Sometimes it feels foreign and it lacks important features such as ctags integration and the ability to edit text.
You can make
less call Vim (assuming
EDITOR=vim) on the file it is currently viewing by pressing v.
less will even put your cursor in the correct location within Vim. When you exit Vim, you will find yourself back at
less. If you made any changes to the file while you were in Vim, they will be reflected in