Article View: comp.editors
Article #62Re: VI - Centering Lines with Found Patterns
From: Jeff Wang
Date: Tue, 03 Nov 1992 03:12
Date: Tue, 03 Nov 1992 03:12
44 lines
2729 bytes
2729 bytes
In article <1992Nov2.231052.24870@kpc.com>, hollasch@kpc.com (Steve Hollasch) writes:
|>
|> I'm trying to set up my .exrc so that when I do a wordsearch, the line
|> containing the next pattern is centered in my window. The current version I
|> have is the following:
|> map n nmzz.`z
|> map N Nmzz.`z
|> The curious thing is that on one version of vi I have, this works as long
|> as lines don't wrap. When it fails, though (always on another machine) it
|> ends up doing the word search for "mzz.`z". In fact, if I do
|> map n nfoo
|> then this will always do a wordsearch for "foo". What's going on here? How
|> can I set up VI so that found text is always centered in my window (as in
|> "z.")?
...close, but not quite. Try -
map n n^[mzz.`z
map N N^[mzz.`z
where ^[ is <Escape>. That works fine. By the way, you mentioned word search.
Try the following two maps out for size (I have either one mapped to ^W (Ctrl-W)
map ^W mw:co-^M`wkmvI ^[`vll?[^a-zA-Z0-9_]^Md0s/\<^[ea\> ^[D"wdd`w@wmzz.`z
"map ^W mw:co-^M`wkmvI ^[`vll?[^a-zA-Z0-9_]^Md0s/^[ea ^[D"wdd`w@wmzz.`z
The first map will take the word your cursor is currently on and find the next
occurrence of that word; note that it looks for an actual word as opposed to the
word being just an embedded pattern of another word. The next occurrence of the
word is centered in your window. You can use this in combination with your n/N
keymaps. To find the defined word as any given pattern in the file, use the
second commented keymap. (As usual, ^M is the <Return> key; ^[ is <Escape>)
Hope that helps :)
--
#====}==) #===(==} #====}==) #===(==} {==)===# (=={====# {==)===# (=={====#
>> Jeff Wang Net : hjiwa@gruc19.nor.chevron.com <<
>> Chevron Petroleum Technology Company Profs : hjiwa (hovmb) <<
>> Geophysical/Geological Applications Phone : (504) 592-6162 <<
>> 935 Gravier Street, Room 1006 Fax : (504) 592-6958 <<
>> New Orleans, Louisiana 70112 Valeo,vales. Die dulci fruimini!! :) <<
>> "Eenie, meenie, chili beanie, your lucky number is... C!" -- Kelly Bundy <<
#===(==} C ... it's not just a language, it's also a chord. {==)===#
Technical Details
Message-ID:
<1992Nov2.211209@gruc19.nor.chevron.com>Path:
arc1-ca.pugleaf.net!sparky!uunet!lhdsy1!nntpserver.chevron.com!gruc19.nor.chevron.com!hjiwaReferences:
<1992Nov2.231052.24870@kpc.com>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!lhdsy1!nntpserver.chevron.com!gruc19.nor.chevron.com!hjiwa From: hjiwa@gruc19.nor.chevron.com (Jeff Wang) Newsgroups: comp.editors Subject: Re: VI - Centering Lines with Found Patterns Message-ID: <1992Nov2.211209@gruc19.nor.chevron.com> Date: 3 Nov 92 03:12:09 GMT References: <1992Nov2.231052.24870@kpc.com> Sender: hjiwa@grus02.nor.chevron.com (Jeff Wang) Organization: Chevron Lines: 44