Came up during lengthy analysis of log files and source code. Some calculators allow expression. Some support history. But all that is quite limited and often is mouse driven. Check into the VIM's :help :let + digging around pointed in direction of the eval() and thus the monster macro was born.

2 statements are at the core:

1. eval(substitute(getline(".")," *=.*$","","")) strip "= whatever" from the end of the string and feed it to eval(). :h eval()

2. :exec "s!!!" where we take everything from the line, save in \1 string before "=", replace the line with "\1 = " plus result of eval(). Requires :set magic. Backslashes had to be doubled since :exec looks for them.

After adding that to vimrc or executing in place, open VIM, type on empty line "2*2", press Esc and F11. You should see "2*2 = 4".

Edit1 A more generic solution is to use the LargeFile script from vim.sf.net, as found out by reader David in the comments below. Starting from version 5 (at the moment of writing available only on author's, Charles Campbell, personal web page.), the script handles properly(*) the buffers with content populated using external commands. The script's main purpose in life is, when opening a large file, to set buffer options to make editing of large files more palatable experience: disable swap file, disable syntax highlighting, discard buffer with large file as soon as it is closed, disable folding, disable undo and so on.

(*) Event used is the BufReadPost, and the size of buffer is evaluated with line2byte(line("$")+1).