Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!sol.ctr.columbia.edu!emory!gatech!usenet.ins.cwru.edu!ysub!psuvm!blekul11!ffaac09 From: FFAAC09@cc1.kuleuven.ac.be (Nicole Delbecque & Paul Bijnens) Newsgroups: comp.editors Subject: Re: Restricted Searches in VI Message-ID: <91112.182420FFAAC09@cc1.kuleuven.ac.be> Date: 22 Apr 91 18:22:20 GMT References: <1991Apr22.071658.1059@cerberus.bhpese.oz.au> Organization: K.U.Leuven - Academic Computing Center Lines: 21 In article <1991Apr22.071658.1059@cerberus.bhpese.oz.au>, fozzy@mips.bhpese.oz.au (Andrew Steele) says: > >In vi is it possible to restrict the range of a search. Specifically >I want to be able to search through just one function in a .c file. >I've inherited some badly written code that has functions that just go on >and on and I'm trying to break them up into smaller units. To do this I need >to be able to find where local variables are used but not if that name is >also used in some other function later on. I don't know of a direct way to accomplish this, but I frequently have the same problem. I solve as follows: - go to the start of the function (using [[ or ]]). - jump to the matching parenthesis of the function (using %) (and complain loudly if the function is using unbalanced {}). - search backwards with ?\ - if I reach the declaration, I am at the top of the function. -- Polleke (Paul Bijnens) Linguistics dept., K. University Leuven, Belgium FFAAC09@cc1.kuleuven.ac.be