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

New text object for Perlish /-delimited strings

Expand Messages
  • Sartak
    Hi gang, I really love text objects. I wish there were more of them. In particular, one for /-delimited strings. These come up a lot in Perl: if ($foo =~ /blah
    Message 1 of 4 , Sep 1, 2007
    • 0 Attachment
      Hi gang,

      I really love text objects. I wish there were more of them. In
      particular, one for /-delimited strings. These come up a lot in Perl:

      if ($foo =~ /blah blah blah/)
      ($hobbit = $lotr) =~ s/Bilbo/Frodo/g;
      for (qw/foo bar baz/)
      print q/ both ' kinds of " /;

      So I wrote a new text object to match these kinds of strings. It was
      literally a one line change. :)

      I think I added all the necessary documentation, let me know if I
      missed a spot. In the todo file there is an item for a different kind
      of / text object, one that has to do with searches. I changed that
      from 'a/' and 'i/' to 'an' and 'in'.

      Shawn M Moore

      --~--~---------~--~----~------------~-------~--~----~
      You received this message from the "vim_dev" maillist.
      For more information, visit http://www.vim.org/maillist.php
      -~----------~----~----~----~------~----~------~--~---
    • ap
      ... My opinion : Why hardcode something, which is easily done with a mapping ? Also, / is just one of many possible perl delimiter. -ap
      Message 2 of 4 , Sep 3, 2007
      • 0 Attachment
        On Sep 1, 6:56 pm, Sartak <sar...@...> wrote:
        > Hi gang,
        >
        > I really love text objects. I wish there were more of them. In
        > particular, one for /-delimited strings. These come up a lot in Perl:
        >
        > if ($foo =~ /blah blah blah/)
        > ($hobbit = $lotr) =~ s/Bilbo/Frodo/g;
        > for (qw/foo bar baz/)
        > print q/ both ' kinds of " /;
        >
        > So I wrote a new text object to match these kinds of strings. It was
        > literally a one line change. :)
        >
        > I think I added all the necessary documentation, let me know if I
        > missed a spot. In the todo file there is an item for a different kind
        > of / text object, one that has to do with searches. I changed that
        > from 'a/' and 'i/' to 'an' and 'in'.
        >
        > Shawn M Moore
        >
        > slash-object.diff
        > 3KDownload

        My opinion : Why hardcode something, which is easily done with a
        mapping ?
        Also, '/' is just one of many possible perl delimiter.

        -ap


        --~--~---------~--~----~------------~-------~--~----~
        You received this message from the "vim_dev" maillist.
        For more information, visit http://www.vim.org/maillist.php
        -~----------~----~----~----~------~----~------~--~---
      • Sartak
        ... Because hardcoding was one new line of code. :) And it wasn t even a particularly difficult line, just adding case / . ... Oh, I m well aware, but I use
        Message 3 of 4 , Sep 3, 2007
        • 0 Attachment
          On 9/3/07, ap <politza@...> wrote:
          >
          >
          >
          > On Sep 1, 6:56 pm, Sartak <sar...@...> wrote:
          > > Hi gang,
          > >
          > > I really love text objects. I wish there were more of them. In
          > > particular, one for /-delimited strings. These come up a lot in Perl:
          > >
          > > if ($foo =~ /blah blah blah/)
          > > ($hobbit = $lotr) =~ s/Bilbo/Frodo/g;
          > > for (qw/foo bar baz/)
          > > print q/ both ' kinds of " /;
          > >
          > > So I wrote a new text object to match these kinds of strings. It was
          > > literally a one line change. :)
          > >
          > > I think I added all the necessary documentation, let me know if I
          > > missed a spot. In the todo file there is an item for a different kind
          > > of / text object, one that has to do with searches. I changed that
          > > from 'a/' and 'i/' to 'an' and 'in'.
          > >
          > > Shawn M Moore
          > >
          > > slash-object.diff
          > > 3KDownload
          >
          > My opinion : Why hardcode something, which is easily done with a
          > mapping ?

          Because hardcoding was one new line of code. :) And it wasn't even a
          particularly difficult line, just adding "case '/'".

          > Also, '/' is just one of many possible perl delimiter.

          Oh, I'm well aware, but I use /.../ a lot.

          >
          > -ap
          >
          >
          > >
          >

          --~--~---------~--~----~------------~-------~--~----~
          You received this message from the "vim_dev" maillist.
          For more information, visit http://www.vim.org/maillist.php
          -~----------~----~----~----~------~----~------~--~---
        • ap
          ... I mostly use + , I want that patched too, please. ;-) ... --~--~---------~--~----~------------~-------~--~----~ You received this message from the
          Message 4 of 4 , Sep 3, 2007
          • 0 Attachment
            On Sep 3, 11:34 pm, Sartak <sar...@...> wrote:
            > On 9/3/07, ap <poli...@...> wrote:
            >
            >
            >
            > > On Sep 1, 6:56 pm, Sartak <sar...@...> wrote:
            > > > Hi gang,
            >
            > > > I really love text objects. I wish there were more of them. In
            > > > particular, one for /-delimited strings. These come up a lot in Perl:
            >
            > > > if ($foo =~ /blah blah blah/)
            > > > ($hobbit = $lotr) =~ s/Bilbo/Frodo/g;
            > > > for (qw/foo bar baz/)
            > > > print q/ both ' kinds of " /;
            >
            > > > So I wrote a new text object to match these kinds of strings. It was
            > > > literally a one line change. :)
            >
            > > > I think I added all the necessary documentation, let me know if I
            > > > missed a spot. In the todo file there is an item for a different kind
            > > > of / text object, one that has to do with searches. I changed that
            > > > from 'a/' and 'i/' to 'an' and 'in'.
            >
            > > > Shawn M Moore
            >
            > > > slash-object.diff
            > > > 3KDownload
            >
            > > My opinion : Why hardcode something, which is easily done with a
            > > mapping ?
            >
            > Because hardcoding was one new line of code. :) And it wasn't even a
            > particularly difficult line, just adding "case '/'".
            >
            > > Also, '/' is just one of many possible perl delimiter.
            >
            > Oh, I'm well aware, but I use /.../ a lot.
            I mostly use '+' , I want that patched too, please. ;-)
            >
            > > -ap


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