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

Re: Activating Windows gVim from the command line

Expand Messages
  • His Nerdship
    ... I have found a working solution: gvim -c /haddock +713 -c :call search( haddock , c ) fish.cpp First do the / search, then go to the specified line,
    Message 1 of 7 , Aug 1, 2012
    • 0 Attachment
      On Aug 2, 12:00 pm, His Nerdship <shol...@...> wrote:
      > Thanks a million, Gary and sc.
      > Gary your solution didn't work in Windows - it has different quoting
      > rules to UNIX.  It's just a matter of experimentation and I will try
      > and bully it into submission later.
      > sc - your solution worked in that it correctly brought up Vim with the
      > cursor on the search expression.  However Vim clearly does not
      > consider this to be a normal search, because the expression was not
      > highlighted and hitting 'n' (for next occurrence) did nothing.
      > However it gave me the break I needed because I just preceded your
      > ":call search" action with a normal search:
      >
      >   gvim +712 -c "/haddock" -c ":call search('haddock')" fish.cpp
      >
      > The initial -c "/haddock" sets up haddock as the current search
      > expression (so that all haddocks are highlighted, and hitting 'n' will
      > find the next one), and the ":call search" takes one to the actual
      > expression.
      > HOWEVER - note I had to subtract 1 from the line no (713) because the
      > "/haddock" takes one to the start of the line, and the ":call search"
      > starts its search from the following line.  This is not perfect, and
      > work in progress, but at least it's progress.
      > Thanks again- Hide quoted text -
      >
      > - Show quoted text -

      I have found a working solution:
      gvim -c "/haddock" +713 -c ":call search('haddock','c')" fish.cpp

      First do the '/' search, then go to the specified line, then do the
      ":call search", i.e. specify the line no AFTER the initial search.
      Also note the parameters passed to search() can be in single quotes.
      The 2nd parameter to search(), 'c', tells search() to accept a match
      at the cursor position. Without this, if the search string is at the
      beginning of the line, Vim will move on to the next occurrence.

      This even works with added conditions, such as case insensitive
      (precede with \c), regular expression (\m), and whole word. This will
      also find the above haddock (looking for 'h.dd.CK'):
      gvim -c"/\c\m\<h.dd.CK\>" +713 -c ":call search('\c\m\<h.dd.CK
      \>','c')" fish.cpp

      Thanks for your help guys. You gave me the break I needed.

      --
      You received this message from the "vim_use" maillist.
      Do not top-post! Type your reply below the text you are replying to.
      For more information, visit http://www.vim.org/maillist.php
    • Ben Fritz
      ... I m glad you got it working, and I don t see any reason to change it. I do have one minor note which may save you some trouble in the future. You seem to
      Message 2 of 7 , Aug 2, 2012
      • 0 Attachment
        On Thursday, August 2, 2012 12:21:02 AM UTC-5, His Nerdship wrote:
        >
        >
        > I have found a working solution:
        >
        > gvim -c "/haddock" +713 -c ":call search('haddock','c')" fish.cpp
        >
        >
        >
        > First do the '/' search, then go to the specified line, then do the
        >
        > ":call search"

        I'm glad you got it working, and I don't see any reason to change it.

        I do have one minor note which may save you some trouble in the future.

        You seem to think vim -c "/pattern" performs a '/' search. It doesn't. What it is doing is specifying the first line of an ex command range via a pattern. I'm not sure where it's documented but specifying a single-line range with no command will just set the cursor to that line.

        :help :range gives details. I wonder if you could make use of a ";" in your range to accomplish what you want with a shorter command.

        --
        You received this message from the "vim_use" maillist.
        Do not top-post! Type your reply below the text you are replying to.
        For more information, visit http://www.vim.org/maillist.php
      • Tony Mechelynck
        ... It has ho helptag of its own, but it is documented as :[range], just after :help gg , in the section about up and down motions. :help +cmd and :help
        Message 3 of 7 , Aug 2, 2012
        • 0 Attachment
          On 02/08/12 16:30, Ben Fritz wrote:
          > On Thursday, August 2, 2012 12:21:02 AM UTC-5, His Nerdship wrote:
          >>
          >>
          >> I have found a working solution:
          >>
          >> gvim -c "/haddock" +713 -c ":call search('haddock','c')" fish.cpp
          >>
          >>
          >>
          >> First do the '/' search, then go to the specified line, then do the
          >>
          >> ":call search"
          >
          > I'm glad you got it working, and I don't see any reason to change it.
          >
          > I do have one minor note which may save you some trouble in the future.
          >
          > You seem to think vim -c "/pattern" performs a '/' search. It doesn't. What it is doing is specifying the first line of an ex command range via a pattern. I'm not sure where it's documented but specifying a single-line range with no command will just set the cursor to that line.

          It has ho helptag of its own, but it is documented as :[range], just
          after ":help gg", in the section about up and down motions.

          ":help +cmd" and ":help [range]" (the section which includes the
          ":range" overview you mention below) are also relevant because more
          detailed, but the section about +something as a Vim argument is ":help -+c".

          >
          > :help :range gives details. I wonder if you could make use of a ";" in your range to accomplish what you want with a shorter command.
          >

          ...for instance
          gvim +713;/haddock/ -c "call search('haddock','c')" fish.cpp
          for the first "haddock" after line 713 (i.e. on line 714 or after).

          This will also find chaddocks if present. See
          :help /\<
          :help /\>
          about specifying word boundaries in a pattern.


          Best regards,
          Tony.
          --
          This is the _LAST_ time I take travel suggestions from Ray Bradbury!

          --
          You received this message from the "vim_use" maillist.
          Do not top-post! Type your reply below the text you are replying to.
          For more information, visit http://www.vim.org/maillist.php
        Your message has been successfully submitted and would be delivered to recipients shortly.