steinbac@hpl-opus.HP.COM (Gunter Steinbach) (10/27/90)
Here is my kludge for telling me the current column, lifted via "cat -v" from my .exrc: " which column map *3 D:.w !expand^V|wc -c;echo "^G";sleep 1^M^Mu Explanation: Delete to end of line "write" out to expand pipe to wc -c beep wait a sec undo the delete (and let's hope that nothing interferes between the leading "D" and the closing "u".) And alas, the file is marked modified afterwards. Guenter Steinbach gunter_steinbach@hplabs.hp.com
Dan_Bloch@TRANSARC.COM (10/29/90)
icsu8209@ming.cs.montana.edu (Glassy) writes: > how do i find what column i'm in, with vi? i know ^G will tell me > what line i'm on, and that #| will take me to the #th column of > the current line... but how do i write a macro to find out what > column i'm in, and display it at the bottom of the screen (like > the output of ^G does)? Well, nothing like a challenge. Here's what I've come up with. You load a buffer, say b, with: :"column 0000000001111111111222222222233333333334444444444555555555566666666667...8 1234567890123456789012345678901234567890123456789012345678901234567890...0 (Slightly contracted to fit on screen. Replace the ...'s.) Then you map a key: :map q xuma"bp`ajj Dj Dd0-$d0-JJx"cdd`a@c How it works, in brief: It puts the ruler lines into the file, gets the tens digit from the first line, the ones digit from the second, and reports them at the bottom of the screen by putting them into a buffer and executing it. It has to be seen to be believed. It's very amusing over a 2400 baud line. A couple of notes: (1) It reveals all kinds of "features" in the nuts and bolts of vi. For instance the "xu" at the beginning is necessary, even though it looks like it doesn't do anything. For some reason running all this stuff in a macro makes vi temporarily "forget" its buffers until a file modification takes place, hence the xu. (2) The best way to install it is by putting the following into your .exrc: :map q ma:r ~/vi.hack^M"b3dd:map q xuma"bp`ajj Dj Dd0-$d0-JJx"cdd`a@c^M`a The first time you use this, it sets up by reading in the ruler buffer from a file, here ~/vi.hack, and remapping q to the actual macro. So the first time, you type it twice. (3) It uses marker a, and buffers b and c. *Very* Rube Goldberg, but it actually does work, and entirely in vi even. And it's pretty much transparent. I tried it under Ultrix and SunOs. Cheers- Dan Bloch dan@transarc.com