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

RE: How to create a abbreviation that expand ".." to "->" correctly?

Expand Messages
  • John Beckett
    ... You ll get a lot of blank lines after the above. Following would condense ... John --~--~---------~--~----~------------~-------~--~----~ You received this
    Message 1 of 9 , Aug 1, 2007
      John R. Culleton wrote:
      > This means putting a \r before each < and a \r after each >.

      In your example, you seem to want \r\r like this:
      :%s/</\r\r&/g
      :%s/>/&\r\r/g

      You'll get a lot of blank lines after the above. Following would condense
      them to a single blank line:

      :%s/\n\n\+/\r\r

      John


      --~--~---------~--~----~------------~-------~--~----~
      You received this message from the "vim_use" maillist.
      For more information, visit http://www.vim.org/maillist.php
      -~----------~----~----~----~------~----~------~--~---
    • Tony Mechelynck
      John R. Culleton wrote: [...] ... As was already said in your earlier thread, the flaw is in using -- these mean start of word and end of word
      Message 2 of 9 , Aug 1, 2007
        John R. Culleton wrote:
        [...]
        > I have a related problem that hasn't been answered yet. In a script I
        > want to massage an html file by addressing its tags. First I want to
        > put each tag on a line by itself. This means putting a \r before each
        > < and a \r after each >. I tried the following commands for this
        > editing but they seem not to work as written:
        > :%s/\</\r\r\&/g
        > :%s/\>/&\r\r/g
        >
        > Can anyone spot the flaws?
        >

        As was already said in your earlier thread, the flaw is in using \< and \> --
        these mean "start of word" and "end of word" respectively. To add a linebreak
        before every < and after every >, use (for instance)

        :%s/</\r</g
        :%s/>/>\r/g

        (without bacslashes before < and >) or, to apply it only to paired < and >

        :%s/<\_[^<>]*>/\r\0\r/g

        which translates as "whenever you see < followed by (any number of anything
        including linebreaks but not < or >) followed by >, add a linebreak before and
        after the whole match.

        The latter might break if there are unpaired < > in comments, but I think that
        even there they would break the HTML syntax.

        With doubled \r you'll get an empty line every time instead of just a linebreak.


        Best regards,
        Tony.
        --
        TALL KNIGHT: We are now no longer the Knights Who Say Ni!
        ONE KNIGHT: Ni!
        OTHERS: Sh!
        ONE KNIGHT: (wispers) Sorry.
        "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD

        --~--~---------~--~----~------------~-------~--~----~
        You received this message from the "vim_use" maillist.
        For more information, visit http://www.vim.org/maillist.php
        -~----------~----~----~----~------~----~------~--~---
      • John R. Culleton
        ... Thanks. The answer(s) to my earlier query didn t make it to me for some reason. -- John Culleton ATTN Publishers/authors: If you don t read you don t
        Message 3 of 9 , Aug 1, 2007
          On Wednesday 01 August 2007, Tony Mechelynck wrote:
          > John R. Culleton wrote:
          > [...]
          >
          > > I have a related problem that hasn't been answered yet. In a
          > > script I want to massage an html file by addressing its tags.
          > > First I want to put each tag on a line by itself. This means
          > > putting a \r before each < and a \r after each >. I tried the
          > > following commands for this
          > >
          > > editing but they seem not to work as written:
          > > :%s/\</\r\r\&/g
          > > :
          > > :%s/\>/&\r\r/g
          > >
          > > Can anyone spot the flaws?
          >
          > As was already said in your earlier thread, the flaw is in using \<
          > and \> -- these mean "start of word" and "end of word"
          > respectively. To add a linebreak before every < and after every >,
          > use (for instance)
          >
          > :%s/</\r</g
          > :%s/>/>\r/g
          >
          > (without bacslashes before < and >) or, to apply it only to paired
          > < and >
          >
          > :%s/<\_[^<>]*>/\r\0\r/g
          >
          > which translates as "whenever you see < followed by (any number of
          > anything including linebreaks but not < or >) followed by >, add a
          > linebreak before and after the whole match.
          >
          > The latter might break if there are unpaired < > in comments, but I
          > think that even there they would break the HTML syntax.
          >
          > With doubled \r you'll get an empty line every time instead of just
          > a linebreak.
          >
          >
          > Best regards,
          > Tony.

          Thanks. The answer(s) to my earlier query didn't make it to me for
          some reason.

          --
          John Culleton
          ATTN Publishers/authors:
          If you don't read you don't succeed.
          Free short list of publishing/marketing books.
          http://wexfordpress.com/tex/shortlist.pdf



          --~--~---------~--~----~------------~-------~--~----~
          You received this message from the "vim_use" maillist.
          For more information, visit http://www.vim.org/maillist.php
          -~----------~----~----~----~------~----~------~--~---
        • Tony Mechelynck
          John R. Culleton wrote: [...] ... Maybe wexfordexpress.com (or whatever) blocked those particular messages, thinking they were spam? Well, now you got it. Best
          Message 4 of 9 , Aug 1, 2007
            John R. Culleton wrote:
            [...]
            > Thanks. The answer(s) to my earlier query didn't make it to me for
            > some reason.
            >

            Maybe wexfordexpress.com (or whatever) blocked those particular messages,
            thinking they were spam? Well, now you got it.


            Best regards,
            Tony.
            --
            Government spending? I don't know what it's all about. I don't know
            any more about this thing than an economist does, and, God knows, he
            doesn't know much.
            -- Will Rogers

            --~--~---------~--~----~------------~-------~--~----~
            You received this message from the "vim_use" maillist.
            For more information, visit http://www.vim.org/maillist.php
            -~----------~----~----~----~------~----~------~--~---
          • Rainux
            Ah, I just forgot the insert mode mappings, this solved my question perfectly! Many thanks for your helps :) ... -- Best Regards Rainux
            Message 5 of 9 , Aug 1, 2007
              Ah, I just forgot the insert mode mappings, this solved my question perfectly!

              Many thanks for your helps :)

              On 8/1/07, Kurt Smith <kwmsmith@...> wrote:
              >
              > On 7/31/07, Rainux <rainux@...> wrote:
              > >
              > > I want when I typed "$this..var" in Vim, it can auto expand ".." to
              > > "->" so I got "$this->var", I've tried the following command in Vim,
              > > but it can work correctly.
              > >
              > > :iab .. ->
              >
              > With this abbreviation, VIM looks for a non-keyword character (usually
              > a \s character, but other non-keyword chars work, too) after the ".."
              > to trigger the abbreviation substitution. See :h 'iskeyword'. If you
              > type a k.w. character after the .. it doesn't kick in, hence
              > $this..var won't trigger, since the "v" is a keyword char.
              >
              > You could use
              >
              > :inoremap .. ->
              >
              > which will always work so long as you type the two dots within a
              > 'timeout' period. See :help 'timeout'. If you'd like two dots next
              > to each other, you'll need to type one dot, wait a 'timeout' period,
              > and type the other.
              >
              > Maybe there is a better way; anyone else?
              >
              > HTH,
              >
              > Kurt
              >
              > >
              >


              --
              Best Regards

              Rainux

              --~--~---------~--~----~------------~-------~--~----~
              You received this message from the "vim_use" maillist.
              For more information, visit http://www.vim.org/maillist.php
              -~----------~----~----~----~------~----~------~--~---
            Your message has been successfully submitted and would be delivered to recipients shortly.