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

last position prior to a 'gqap'

Expand Messages
  • Pritesh Mistry
    Hi Guys, How do I get back to the last place where I was prior to formating the paragraph, using a mapping. What exactly I want to achieve is to remain in
    Message 1 of 5 , Sep 5, 2001
      Hi Guys,

      How do I get back to the last place where I was prior to formating
      the paragraph, using a mapping.

      What exactly I want to achieve is to remain in place, or atleast get
      back to the place where I was, after formatting a paragraph.

      I tried to mark the position where I was while recording a macro,
      however, when I try to get back to that position after formating the
      para, it says mark not found. The only mark that I was able to use
      was `^, however, I want to be able to do this even in the normal
      mode, using a mapping.

      TIA!


      __________________________________________________
      Do You Yahoo!?
      Get email alerts & NEW webcam video instant messaging with Yahoo! Messenger
      http://im.yahoo.com
    • Stefan Roemer
      ... How about inserting a special character that does not occur in the text ... You may define an imap as well. Hope that helps. Best regards Stefan
      Message 2 of 5 , Sep 5, 2001
        On Wed, Sep 05, 2001, Pritesh Mistry wrote:
        > How do I get back to the last place where I was prior to formating
        > the paragraph, using a mapping.
        >
        > What exactly I want to achieve is to remain in place, or at least get
        > back to the place where I was, after formatting a paragraph.

        How about inserting a special character that does not occur in the text
        otherwise, jump to that after formatting and remove it afterwards:

        :nmap ,q i`<esc>gqap/`<cr>x

        You may define an 'imap' as well.

        Hope that helps.

        Best regards

        Stefan
      • Pritesh Mistry
        ... [...] ... Okay, so does this means that you tend to lose all your marks whenever you gq-format your text? Or, am I missing something! Is this expected? Or,
        Message 3 of 5 , Sep 5, 2001
          --- Stefan Roemer <roemer@...> wrote:
          > > How do I get back to the last place where I was prior to formating
          > > the paragraph, using a mapping.
          [...]
          > :nmap ,q i`<esc>gqap/`<cr>x
          >

          Okay, so does this means that you tend to lose all your marks whenever
          you gq-format your text? Or, am I missing something!

          Is this expected? Or, is there a way out? Or, is this a bug?

          rgds,



          __________________________________________________
          Do You Yahoo!?
          Get email alerts & NEW webcam video instant messaging with Yahoo! Messenger
          http://im.yahoo.com
        • Benji Fisher
          ... I think that reformatting counts as deleting and replacing lines. One alternative is to use the Mark() function in foo.vim:
          Message 4 of 5 , Sep 5, 2001
            Pritesh Mistry wrote:
            >
            > --- Stefan Roemer <roemer@...> wrote:
            > > > How do I get back to the last place where I was prior to formating
            > > > the paragraph, using a mapping.
            > [...]
            > > :nmap ,q i`<esc>gqap/`<cr>x
            > >
            >
            > Okay, so does this means that you tend to lose all your marks whenever
            > you gq-format your text? Or, am I missing something!
            >
            > Is this expected? Or, is there a way out? Or, is this a bug?
            >
            > rgds,

            I think the marks go away. From :help marks:

            > ... If you delete a line that contains a mark, that mark is erased.

            I think that reformatting counts as deleting and replacing lines.

            One alternative is to use the Mark() function in foo.vim:
            http://vim.sourceforge.net/scripts/script.php?script_id=72
            This takes you to the same line and (virtual) column, which is probably not
            what you want. Maybe line2byte() will get you close to where you want to be.

            HTH --Benji Fisher
          • Pritesh Mistry
            ... [...] ... [...] ... Yes indeed Benji, this seems to be the correct solution. Thanks very much. :-) __________________________________________________ Do
            Message 5 of 5 , Sep 5, 2001
              --- Benji Fisher <benji@...> wrote:
              > Pritesh Mistry wrote:
              > >
              > > --- Stefan Roemer <roemer@...> wrote:
              > > > > How do I get back to the last place where I was prior to formating
              > > > > the paragraph, using a mapping.
              > > [...]
              [...]
              > > Okay, so does this means that you tend to lose all your marks whenever
              > > you gq-format your text? Or, am I missing something!
              [...]
              >
              > I think the marks go away. From :help marks:
              >
              > > ... If you delete a line that contains a mark, that mark is erased.
              >
              > I think that reformatting counts as deleting and replacing lines.
              >
              > One alternative is to use the Mark() function in foo.vim:
              > http://vim.sourceforge.net/scripts/script.php?script_id=72
              > This takes you to the same line and (virtual) column, which is probably not
              > what you want. Maybe line2byte() will get you close to where you want to be.

              Yes indeed Benji, this seems to be the correct solution. Thanks very much. :-)


              __________________________________________________
              Do You Yahoo!?
              Get email alerts & NEW webcam video instant messaging with Yahoo! Messenger
              http://im.yahoo.com
            Your message has been successfully submitted and would be delivered to recipients shortly.