From: Hari Krishna Dara, Fri, October 20, 2006 2:26 am > > Often there are questions on this list on how to capture every key > press from a user, and the answer is that it can't, unless you map > all keys. But even if you map all keys, it is not flexible enough. > Here is a trick with recursive <expr> maps and getchar() to get all > keys pass through your function. You can do whatever you want with > the keys, swallow them or pass them to Vim.
This is exactly how Cream's "column mode" works. We've been using this for several Vim versions, prior to the :try feature. It works great, but the only drawback I've ever found is the dependency on :redraw. You will find that when extending a selection area it requires the additional exclamation point (:redraw!) since that is the only way to update the background. Unfortunately, this greatly slows down the display response. The solution would be a Vim feature to refresh only the area of the selection change rather than the whole text area. But otherwise, this is a terrific way to loop on user keystrokes. If anyone is interested in seeing how this can develop (various key combinations, handling issues with listchars, etc.) take a look at: http://cream.cvs.sourceforge.net/cream/cream/cream-columns.vim?view=markup -- Steve Hall [ digitect dancingpaper com ]