cd@hrc63.co.uk (Colin Denman "GECCL") (04/27/89)
Dear Auntie, I would like a vi macro that behaves like control-], but takes the word under the cursor as a search pattern. I can see how to yank the word, but not how to search for the contents of a buffer. Any advice ? I use SunOS3.5.
sjs@spectral.ctt.bellcore.com (Stan Switzer) (04/27/89)
In article <238@crdgw1.crd.ge.com> barnett@crdgw1.crd.ge.com (Bruce G. Barnett) writes: > In article <175@inf.ethz.ch>, wyle@inf (Mitchell Wyle) writes: > >" Map insert mode keys > >map! #in #include > >map! #de #define > >map! #un #undef > >map! #el #else > >map! #en #endif > > I use to do this, but stopped because if I cut some text > out of one window system, and pasted it into another window > system, the "#include" would become "#includeclude". Back when I used to use VI I had some mappings like this too. Here are a few of the good ones: map! '' ' map! '// /* map! '/* /* */2hi map! 'in # include "X.h"3hs map! 'is # include <X.h>3hs map! 'de # define map! 'if if ( ) { map! 'ei else if ( ) { map! 'el else { map! 'ie if ( ) { map! 'wh while ( ) { map! 'fo for ( ) { map! 'br break; map! 're return;i map! 'sw switch ( ) { map! 'ca case : map! 'fu /* They are set up to work with auto-indent ON. Using a "'" character for a prefix for two-character abbreviations pretty much makes sure you'll not have any conflicts with valid C syntax. I'm not sure, but I think I stole this idea off of Eric Krohn. Stan Switzer sjs@ctt.bellcore.com
aap@praxis.co.uk (Andy Pryor) (04/28/89)
In article <575@hrc63.co.uk> cd@hrc63.co.uk (Colin Denman "GECCL") writes: > >Dear Auntie, >I would like a vi macro that behaves like control-], but takes the word >under the cursor as a search pattern. I can see how to yank the word, but >not how to search for the contents of a buffer. Any advice ? I use SunOS3.5. I have the following in my vi start-up file that binds the function you want to the FIND key on my vt220. You should be able to adapt it to what you want. (I have changed the control characters into printables.) " FIND = find next occurrence of current word :map ^[[1~ yeo^V^[pI/^V^["kdd@k This only looks in the current buffer of course. If you want to search a set of files in a similar fashion to ^], it will involve generating a macro that invokes an external command like grep. Needless to say, I haven't tried this! Hope this helps. Andy Pryor Praxis Systems plc, 20 Manvers St, BATH BA1 1PX, UK Tel: +44 225 444700 ...!uunet!mcvax!ukc!praxis!aap
rahardj@ccu.umanitoba.ca (Budi Rahardjo) (10/21/89)
I need a good book to learn vi macros. Most of the books I've read have basic vi commands only. thanks Budi Rahardjo
carl@mugwump.UK.Sun.COM (Carl Johnson - Sun EHQ - MIS) (01/24/91)
Greetings, I finally got around to looking at Tom Christiansen's (Thanks Tom) instructive .exrc file which he posted a while back, however, I am having a some trouble with the meta macros which do not seem to accept the '\' char, here is the bit of code :- " META MACROS, all begin with meta-key '\' ; more later in file " map ^V \ " so can use both ^I and \ for meta-key " map * i^M^[ " split line " map \/ dePo/\<^V^[pA\>^V^["wdd@w " find current word, uses w buffer " map \w :w^M " write out the file " All I get is a beep from the keyboard whenever I try to use one of these. I am also having problems with the automatic commenting macro :- " " from edit mode, this comments a line map ^X ^i/* ^[A */^[^ " I know the ^X is a control char but is the ^i? If so, how do I get it? I tried the usual way of hitting ctrl-V first but this didn't work. I get the feeling I am missing something obvious, any help or RTFM's greatfully appreciated. Email me and I will summarise. Cheers, Carl.
tchrist@convex.COM (Tom Christiansen) (01/25/91)
From the keyboard of carl@mugwump.UK.Sun.COM (Carl Johnson - Sun EHQ - MIS): : I finally got around to looking at Tom Christiansen's (Thanks Tom) certainly. : map ^V \ : " so can use both ^I and \ for meta-key there's a control-I (tab), then a space, after the ^V. : I am also having problems with the automatic commenting macro :- (although the \c macro is cooler.) : " from edit mode, this comments a line : map ^X ^i/* ^[A */^[^ : I know the ^X is a control char but is the ^i? If so, how do I : get it? I tried the usual way of hitting ctrl-V first but this didn't work. the ^i is a ^ (caret) plus an i. --tom -- "Hey, did you hear Stallman has replaced /vmunix with /vmunix.el? Now he can finally have the whole O/S built-in to his editor like he always wanted!" --me (Tom Christiansen <tchrist@convex.com>)
dattier@ddsw1.MCS.COM (David W. Tamkin) (01/29/91)
tchrist@convex.COM (Tom Christiansen) wrote in <1991Jan25.075031.11182@convex.com>: | From the keyboard of carl@mugwump.UK.Sun.COM (Carl Johnson - Sun EHQ - MIS): | : I am also having problems with the automatic commenting macro :- [Carl quotes a previous recommendation by Tom:] | : " from edit mode, this comments a line | : map ^X ^i/* ^[A */^[^ [Carl asks:] | : I know the ^X is a control char but is the ^i? If so, how do I | : get it? I tried the usual way of hitting ctrl-V first but this didn't work. [Tom explains:] | the ^i is a ^ (caret) plus an i. vi's I does the same thing is ^i, is shorter to type, and doesn't confuse people in print. __ David Tamkin Box 7002 Des Plaines IL 60018-7002 708 518 6769 312 693 0591 MCI Mail: 426-1818 GEnie: D.W.TAMKIN CIS: 73720,1570 dattier@ddsw1.mcs.com [csh is] a real pain. I've heard Bill Joy will tell you he didn't understand expression evaluation when he wrong it. -- Tom Christiansen in <110255@convex.convex.com>
dylan@ibmpcug.co.uk (Matthew Farwell) (01/30/91)
In article <1991Jan28.164208.28876@ddsw1.MCS.COM> dattier@ddsw1.MCS.COM (David W. Tamkin) writes: >tchrist@convex.COM (Tom Christiansen) wrote in ><1991Jan25.075031.11182@convex.com>: >| From the keyboard of carl@mugwump.UK.Sun.COM (Carl Johnson - Sun EHQ - MIS): >| : I am also having problems with the automatic commenting macro :- >[Carl quotes a previous recommendation by Tom:] >| : " from edit mode, this comments a line >| : map ^X ^i/* ^[A */^[^ >[Carl asks:] >| : I know the ^X is a control char but is the ^i? If so, how do I >| : get it? I tried the usual way of hitting ctrl-V first but this didn't work. >[Tom explains:] > >| the ^i is a ^ (caret) plus an i. > >vi's I does the same thing is ^i, is shorter to type, and doesn't confuse >people in print. or you could use 0, which takes you to the first character on a line, whereas ^ takes you to the first non-whitespace character. Dylan. -- Matthew J Farwell | Email: dylan@ibmpcug.co.uk The IBM PC User Group, PO Box 360,| ...!uunet!ukc!ibmpcug!dylan Harrow HA1 4LQ England | CONNECT - Usenet Access in the UK!! Phone: +44 81-863-1191 | Sun? Don't they make coffee machines?
carl@mugwump.UK.Sun.COM (Carl Johnson - Sun EHQ - MIS) (01/30/91)
map ^X ^i/* ^[A */^[^ Someone (I forget who but thanks anyway) posted :- >>vi's I does the same thing is ^i, is shorter to type, and doesn't confuse >>people in print. > Then :- >or you could use 0, which takes you to the first character on a line, >whereas ^ takes you to the first non-whitespace character. > >Dylan. >-- >Matthew J Farwell | Email: dylan@ibmpcug.co.uk >The IBM PC User Group, PO Box 360,| ...!uunet!ukc!ibmpcug!dylan >Harrow HA1 4LQ England | CONNECT - Usenet Access in the UK!! >Phone: +44 81-863-1191 | Sun? Don't they make coffee machines? I think the idea of using ^ is better though, for commenting code which has the comments indented, so that the /* lines up correctly. Cheers, Carl. IBM PC? - Aint that a brand of doorstop?
dattier@vpnet.chi.il.us (David W. Tamkin) (02/01/91)
carl@mugwump.UK.Sun.COM (Carl Johnson) wrote in <4725@male.EBay.Sun.COM>: | map ^X ^i/* ^[A */^[^ | Someone (I forget who but thanks anyway) posted :- I wish the IRS would forget me as readily as you did, Carl. You're welcome anyway. I had written, in reply to Tom Christiansen's original answer: | >>vi's I does the same thing is ^i, is shorter to type, and doesn't confuse | >>people in print. Then Matthew J. "Dylan" Farwell commented: | >or you could use 0, which takes you to the first character on a line, | >whereas ^ takes you to the first non-whitespace character. So Carl said, | I think the idea of using ^ is better though, for commenting code which has | the comments indented, so that the /* lines up correctly. Dylan's suggestion of just "0" doesn't get you into insert mode. 0i would. The question is whether one wants to preserve an existing left margin (then use I or caret-i) or to put the comment leader at the left edge of the screen (then use 0i). If the existing text already begins at the left edge of the screen, all three behave the same. David Tamkin PO Box 7002 Des Plaines IL 60018-7002 dattier@vpnet.chi.il.us GEnie:D.W.TAMKIN CIS:73720,1570 MCIMail:426-1818 708 518 6769 312 693 0591