Loading ...
Sorry, an error occurred while loading the content.

Re: Filetype detect for *.tex

Expand Messages
  • Bram Moolenaar
    ... You don t need a startline parameter, you can set the cursor to where you want the search to start. You just need to save and restore the cursor (I ll
    Message 1 of 16 , Mar 2, 2006
    • 0 Attachment
      Benji Fisher wrote:

      > On Wed, Mar 01, 2006 at 10:54:54AM -0800, Gerald Lai wrote:
      > > On Wed, 1 Mar 2006, Benji Fisher wrote:
      > > [snip]
      > > >Is there any way to catch a match at the very start of the file with
      > > >search(), analogous to
      > > >
      > > >:0/<pat>/
      > >
      > > :0/<pat>/ places the cursor at the start of the line of the first
      > > occurence of <pat> from the beginning of the file. This is the same as:
      > >
      > > :call search('\%^\_.\{-}\zs.*<pat>')
      > >
      > > To place the cursor at the beginning of the search occurence, remove
      > > ".*":
      > >
      > > :call search('\%^\_.\{-}\zs<pat>')
      > >
      > > The anchors for start and end-of-file are \%^ and \%$, respectively :)
      > > --
      > > Gerald
      >
      > Thanks, that works. Still, I wonder whether this might be slower
      > than :0/<pat> . Maybe, before we get too used to the new stopline
      > parameter to search() and related functions, we should ask Bram to add a
      > startline parameter before it (both optional, of course).
      >
      > For example, suppose the cursor is on the first line and I want to
      > search for something starting at Line 1000 without moving the cursor. I
      > could use search('\%>999l<pat>'). If I understand how the search engine
      > works (and I have never dived into the code, so maybe not) then this
      > searches every character up to Line 1000, checking to see if it matches.
      > It would be more readable, and faster if I am right, to use
      > search('<pat>', '', 1000, 2000), where '' is the flags parameter, 1000
      > is my suggested startline parameter, and 2000 is the new stopline
      > parameter.

      You don't need a startline parameter, you can set the cursor to where
      you want the search to start. You just need to save and restore the
      cursor (I'll make that a bit simpler).

      --
      How To Keep A Healthy Level Of Insanity:
      9. As often as possible, skip rather than walk.

      /// Bram Moolenaar -- Bram@... -- http://www.Moolenaar.net \\\
      /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
      \\\ download, build and distribute -- http://www.A-A-P.org ///
      \\\ help me help AIDS victims -- http://www.ICCF.nl ///
    Your message has been successfully submitted and would be delivered to recipients shortly.