Stewart Stremler wrote: > begin quoting James G. Sack (jim) as of Wed, Jan 31, 2007 at 02:56:56PM > -0800: >> Stewart Stremler wrote: >>> .. >>> Pick your keystroke to use. I often use ^P, as I never use it otherwise. >>> >>> :map ^V^P 0a ^V^[/^[0-9][A-Z]^V^M >>> /^[0-9][A-Z] >>> >>> Then ^P until done. >> Could you interpret the above keystrokes in the wonderfully-nice way you >> did for the re? Pleeze? > > Oh, sorry, I wasn't sure anyone really cared. > > Read the above like so: > > : -> go to command mode > map -> define a keystroke mapping > ^V -> (control+V) escape the next character (i.e., don't interpret yet) > ^P -> (control+P) the keystroke were binding > 0 -> go to the start of the current line (column 0) > a -> append (insert) mode > -> append a space > ^V -> escape the next character > ^[ -> the escape keycode (just hit escape) to go to edit mode > / -> start a search > ^[0-9][A-Z] -> pattern we're looking for (digit + uppercase at start of line) > ^V -> escape the next character > ^M -> (control+M) CR, or "return" keystroke, which ends the search > pattern and performs the search >
OK, thanks! this way of explaining sure makes things easier to follow. For those with even weaker mastery of vi than mine, I humbly offer minor footnotes to your explanation. [1] The 'a' command to enter append mode, places the cursor AFTER the current character (ie, after the digit). If you didn't know this, it wouldn't be clear that the macro performs the desired editing operation. [2] The '/^[0-9][A-Z]' command executed after storing the mapping performs the initial search for the next line matching the pattern. The instruction '^P until done' means after *noticing* that the last search found something (eg, *if/while* it did), execute the macro that changes the found line and conveniently repeats the search for the next match. Also, your convention of reserving an otherwise unmapped character (^P) for throwaway macros is worth noting. Sorry to belabor the obvious, but I think your thoughtful operating practice is worth explaining in terms that even I will likely remember. Thanks, again ..jim -- [email protected] http://www.kernel-panic.org/cgi-bin/mailman/listinfo/kplug-list
