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

[plugin] targets.vim - adds many text objects in the spirit of Vim, including next and last text objects

Expand Messages
  • Christian Wellenbrock
    This is my first Vim plugin and I would appreciate some honest feedback. Let me know what you think! :) https://github.com/wellle/targets.vim -- -- You
    Message 1 of 13 , Feb 6, 2014
    • 0 Attachment
      This is my first Vim plugin and I would appreciate some honest feedback. Let me know what you think! :)

      https://github.com/wellle/targets.vim

      --
      --
      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

      ---
      You received this message because you are subscribed to the Google Groups "vim_use" group.
      To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@....
      For more options, visit https://groups.google.com/groups/opt_out.
    • Marcin Szamotulski
      ... Nice. There is a patch for miX where X can be anything for example mi, will be what in your plugin is i, . Check out recent discussions on VimDev.
      Message 2 of 13 , Feb 6, 2014
      • 0 Attachment
        On 13:43 Thu 06 Feb , Christian Wellenbrock wrote:
        > This is my first Vim plugin and I would appreciate some honest feedback. Let me know what you think! :)
        >
        > https://github.com/wellle/targets.vim


        Nice. There is a patch for "miX" where X can be anything for example
        "mi," will be what in your plugin is "i,". Check out recent discussions
        on VimDev. I can see the advantage of your text objects over the
        `native` ones.

        Best regards,
        Marcin

        --
        --
        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

        ---
        You received this message because you are subscribed to the Google Groups "vim_use" group.
        To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@....
        For more options, visit https://groups.google.com/groups/opt_out.
      • Christian Wellenbrock
        ... You are absolutely right. Here are two related discussions over at vim_dev. [1] Patch to utilize undefined text-objects [2] patch for block textobj search
        Message 3 of 13 , Feb 6, 2014
        • 0 Attachment
          On Thursday, February 6, 2014 11:58:19 PM UTC+1, coot_. wrote:
          > On 13:43 Thu 06 Feb , Christian Wellenbrock wrote:
          >
          > > This is my first Vim plugin and I would appreciate some honest feedback. Let me know what you think! :)
          >
          > >
          >
          > > https://github.com/wellle/targets.vim
          >
          >
          >
          >
          >
          > Nice. There is a patch for "miX" where X can be anything for example
          >
          > "mi," will be what in your plugin is "i,". Check out recent discussions
          >
          > on VimDev. I can see the advantage of your text objects over the
          >
          > `native` ones.
          >
          >
          >
          > Best regards,
          >
          > Marcin

          You are absolutely right. Here are two related discussions over at vim_dev.

          [1] Patch to utilize undefined text-objects
          [2] patch for block textobj search

          We're also having a small discussion about these patches over at /r/vim. [3]

          One major difference between our approaches is that I treat separators differently from quotes, as illustrated in the `da,` example. If I'm not mistaken that would not be possible with these patches.

          [1] https://groups.google.com/forum/#!topic/vim_dev/pZxLAAXxk0M
          [2] https://groups.google.com/forum/#!topic/vim_dev/I9sKIJh-uT4
          [3] http://redd.it/1x7pfr

          --
          --
          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

          ---
          You received this message because you are subscribed to the Google Groups "vim_use" group.
          To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@....
          For more options, visit https://groups.google.com/groups/opt_out.
        • Andrew Stewart
          ... Great stuff! I can t believe that s your first Vim plugin. In terms of VimL, I don t think you need to save cpoptions in your autoloaded files because
          Message 4 of 13 , Feb 7, 2014
          • 0 Attachment
            On 6 Feb 2014, at 22:43, Christian Wellenbrock <christian.wellenbrock@...> wrote:
            > This is my first Vim plugin and I would appreciate some honest feedback. Let me know what you think! :)
            >
            > https://github.com/wellle/targets.vim

            Great stuff! I can't believe that's your first Vim plugin.

            In terms of VimL, I don't think you need to save cpoptions in your autoloaded files because you've already done that in plugin/targets.vim - though I'm not 100% certain.

            Anyway, I've wanted for ages what your plugin provides and I'm delighted to use it.

            Regarding the various mailing list threads about text objects: I think the existence of multiple plugins offering new text objects is evidence of demand for Vim to beef up its text objects. They are one of the most useful parts of Vim and enhancing this area would, I think, increase Vim's utility. I know adding features complicates everything but because text objects are so important I feel the benefits outweigh the costs.

            Yours,
            Andy Stewart

            --
            --
            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

            ---
            You received this message because you are subscribed to the Google Groups "vim_use" group.
            To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@....
            For more options, visit https://groups.google.com/groups/opt_out.
          • Christian Wellenbrock
            ... Thank you for you kind words! I looked into popular plugins and found that they often saved cpoptions in autoload, so I figured it can t hurt. Also I
            Message 5 of 13 , Feb 7, 2014
            • 0 Attachment
              On Friday, February 7, 2014 9:51:11 AM UTC+1, Andrew Stewart wrote:
              > On 6 Feb 2014, at 22:43, Christian Wellenbrock wrote:
              >
              > > This is my first Vim plugin and I would appreciate some honest feedback. Let me know what you think! :)
              >
              > >
              >
              > > https://github.com/wellle/targets.vim
              >
              >
              >
              > Great stuff! I can't believe that's your first Vim plugin.
              >
              >
              >
              > In terms of VimL, I don't think you need to save cpoptions in your autoloaded files because you've already done that in plugin/targets.vim – though I'm not 100% certain.
              >
              >
              >
              > Anyway, I've wanted for ages what your plugin provides and I'm delighted to use it.
              >
              >
              >
              > Regarding the various mailing list threads about text objects: I think the existence of multiple plugins offering new text objects is evidence of demand for Vim to beef up its text objects. They are one of the most useful parts of Vim and enhancing this area would, I think, increase Vim's utility. I know adding features complicates everything but because text objects are so important I feel the benefits outweigh the costs.
              >
              >
              >
              > Yours,
              >
              > Andy Stewart

              Thank you for you kind words!

              I looked into popular plugins and found that they often saved cpoptions in autoload, so I figured it can't hurt. Also I believe that plugin/targets.vim gets source when Vim starts, while autoload/targets.vim gets sourced only when the first of its text objects is used. So it makes sense to restore cpoptions in both of these cases.

              I agree with your attitude about the text object discussions. Because of Vim's grammar both commands and text objects are expressiveness multipliers.

              --
              --
              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

              ---
              You received this message because you are subscribed to the Google Groups "vim_use" group.
              To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@....
              For more options, visit https://groups.google.com/groups/opt_out.
            • BPJ
              ... FWIW I would like to be able to define text objects in terms of syntax objects (yes I just made that term up, I mean primarily the piece of text seleced
              Message 6 of 13 , Feb 7, 2014
              • 0 Attachment
                2014-02-07 09:51, Andrew Stewart skrev:
                > Regarding the various mailing list threads about text objects: I think the existence of multiple plugins offering new text objects is evidence of demand for Vim to beef up its text objects. They are one of the most useful parts of Vim and enhancing this area would, I think, increase Vim's utility. I know adding features complicates everything but because text objects are so important I feel the benefits outweigh the costs.

                FWIW I would like to be able to define text objects in terms of
                'syntax objects' (yes I just made that term up, I mean primarily
                the piece of text seleced by a :syn match or :syn region as
                identified by the syntax group it is connected with). To my mind
                they are related because a 'syntax object' can be thought of as a
                'thing' in the text which you might want to do stuff to. At least
                I would like to be able to define objects using a
                command/function syntax similar to :syn region.

                I hope this idea isn't totally naive. I'm just a user having done
                some limited forays into scripting Vim, lacking deeper
                knowledge/understanding.

                /bpj

                --
                --
                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

                ---
                You received this message because you are subscribed to the Google Groups "vim_use" group.
                To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@....
                For more options, visit https://groups.google.com/groups/opt_out.
              • Christian Wellenbrock
                ... That s actually an interesting idea. I m not sure how useful it would be though. Looking at some local code files the regions with common syntax are
                Message 7 of 13 , Feb 7, 2014
                • 0 Attachment
                  On Friday, February 7, 2014 4:08:06 PM UTC+1, BPJ wrote:
                  > 2014-02-07 09:51, Andrew Stewart skrev:
                  >
                  > > Regarding the various mailing list threads about text objects: I think the existence of multiple plugins offering new text objects is evidence of demand for Vim to beef up its text objects. They are one of the most useful parts of Vim and enhancing this area would, I think, increase Vim's utility. I know adding features complicates everything but because text objects are so important I feel the benefits outweigh the costs.
                  >
                  >
                  >
                  > FWIW I would like to be able to define text objects in terms of
                  >
                  > 'syntax objects' (yes I just made that term up, I mean primarily
                  >
                  > the piece of text seleced by a :syn match or :syn region as
                  >
                  > identified by the syntax group it is connected with). To my mind
                  >
                  > they are related because a 'syntax object' can be thought of as a
                  >
                  > 'thing' in the text which you might want to do stuff to. At least
                  >
                  > I would like to be able to define objects using a
                  >
                  > command/function syntax similar to :syn region.
                  >
                  >
                  >
                  > I hope this idea isn't totally naive. I'm just a user having done
                  >
                  > some limited forays into scripting Vim, lacking deeper
                  >
                  > knowledge/understanding.
                  >
                  >
                  >
                  > /bpj

                  That's actually an interesting idea. I'm not sure how useful it would be though. Looking at some local code files the regions with common syntax are usually strings, comments or single words. All of which can be operated on with default text objects.

                  Do you see real world editing tasks where you would benefit from selecting all text inside the current syntax region?

                  --
                  --
                  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

                  ---
                  You received this message because you are subscribed to the Google Groups "vim_use" group.
                  To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@....
                  For more options, visit https://groups.google.com/groups/opt_out.
                • glts
                  ... Nice work! You have great attention to detail. Dealing with all corner cases is painful, I can say that because I struggled a lot with corner cases in
                  Message 8 of 13 , Feb 7, 2014
                  • 0 Attachment
                    On Thursday, February 6, 2014 10:43:44 PM UTC+1, Christian Wellenbrock wrote:
                    > This is my first Vim plugin and I would appreciate some honest feedback. Let me know what you think! :)
                    >
                    > https://github.com/wellle/targets.vim

                    Nice work! You have great attention to detail. Dealing with all corner
                    cases is painful, I can say that because I struggled a lot with corner
                    cases in textobj-comment.

                    Speaking of which: I like your 'seeking' idea, and I wonder if it could
                    be used in other custom text objects, too. For example, "dac" deletes a
                    comment, "danc" deletes a following comment, "daNc" deletes a preceding
                    comment, ... (I would use "N" not "l" to go in the other direction.)

                    Probably a lot of work to implement, though.


                    --
                    David

                    --
                    --
                    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

                    ---
                    You received this message because you are subscribed to the Google Groups "vim_use" group.
                    To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@....
                    For more options, visit https://groups.google.com/groups/opt_out.
                  • glts
                    ... Interesting idea. It s a generalisation of the syntax highlighting text object. This has been around for a long time by the way, might want to check it
                    Message 9 of 13 , Feb 7, 2014
                    • 0 Attachment
                      On Friday, February 7, 2014 4:08:06 PM UTC+1, BPJ wrote:
                      > 2014-02-07 09:51, Andrew Stewart skrev:
                      > > Regarding the various mailing list threads about text objects: I think the existence of multiple plugins offering new text objects is evidence of demand for Vim to beef up its text objects. They are one of the most useful parts of Vim and enhancing this area would, I think, increase Vim's utility. I know adding features complicates everything but because text objects are so important I feel the benefits outweigh the costs.
                      >
                      > FWIW I would like to be able to define text objects in terms of
                      > 'syntax objects' (yes I just made that term up, I mean primarily
                      > the piece of text seleced by a :syn match or :syn region as
                      > identified by the syntax group it is connected with). To my mind
                      > they are related because a 'syntax object' can be thought of as a
                      > 'thing' in the text which you might want to do stuff to. At least
                      > I would like to be able to define objects using a
                      > command/function syntax similar to :syn region.
                      >
                      > I hope this idea isn't totally naive. I'm just a user having done
                      > some limited forays into scripting Vim, lacking deeper
                      > knowledge/understanding.

                      Interesting idea.

                      It's a generalisation of the syntax highlighting text object. This has
                      been around for a long time by the way, might want to check it out:

                      https://github.com/kana/vim-textobj-syntax


                      --
                      David

                      --
                      --
                      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

                      ---
                      You received this message because you are subscribed to the Google Groups "vim_use" group.
                      To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@....
                      For more options, visit https://groups.google.com/groups/opt_out.
                    • Christian Wellenbrock
                      ... Thank you! You might want to take a look at how `seek`, `next` and `nextp` are implemented [1]. It s basically just moving into the range of where the
                      Message 10 of 13 , Feb 7, 2014
                      • 0 Attachment
                        On Friday, February 7, 2014 5:44:25 PM UTC+1, glts wrote:
                        > On Thursday, February 6, 2014 10:43:44 PM UTC+1, Christian Wellenbrock wrote:
                        > > This is my first Vim plugin and I would appreciate some honest feedback. Let me know what you think! :)
                        > >
                        > > https://github.com/wellle/targets.vim
                        >
                        > Nice work! You have great attention to detail. Dealing with all corner
                        > cases is painful, I can say that because I struggled a lot with corner
                        > cases in textobj-comment.
                        >
                        > Speaking of which: I like your 'seeking' idea, and I wonder if it could
                        > be used in other custom text objects, too. For example, "dac" deletes a
                        > comment, "danc" deletes a following comment, "daNc" deletes a preceding
                        > comment, ... (I would use "N" not "l" to go in the other direction.)
                        >
                        > Probably a lot of work to implement, though.
                        >
                        >
                        > --
                        > David

                        Thank you!

                        You might want to take a look at how `seek`, `next` and `nextp` are implemented [1]. It's basically just moving into the range of where the normal text object would work before invoking that text object. Depending on how `textobj-comment` is implemented this could be a pretty straight forward addition.

                        [1] https://github.com/wellle/targets.vim/blob/master/autoload/targets.vim

                        --
                        --
                        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

                        ---
                        You received this message because you are subscribed to the Google Groups "vim_use" group.
                        To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@....
                        For more options, visit https://groups.google.com/groups/opt_out.
                      • David Fishburn
                        ... I think a simple case might be when you are editing a HTML file. You can embedded different syntax objects within it, javascript, perl, php, ... Some of
                        Message 11 of 13 , Feb 7, 2014
                        • 0 Attachment
                          ...
                           
                          > FWIW I would like to be able to define text objects in terms of
                          > 'syntax objects' (yes I just made that term up, I mean primarily
                          > the piece of text seleced by a :syn match or :syn region as
                          > identified by the syntax group it is connected with).
                          ...
                          That's actually an interesting idea. I'm not sure how useful it would be though. Looking at some local code files the regions with common syntax are usually strings, comments or single words. All of which can be operated on with default text objects.

                          Do you see real world editing tasks where you would benefit from selecting all text inside the current syntax region?

                          I think a simple case might be when you are editing a HTML file.

                          You can embedded different syntax objects within it, javascript, perl, php, ...

                          Some of the html syntax files do this already.  They can highlight Javascript as "javascript" and highlight the rest of the page as "html".

                          So, I might like to highlight my "javascript" code using one of these text objects and hit = to format it.

                          That was one of the first usages that came to mind to me.

                          David
                           

                          --
                          --
                          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
                           
                          ---
                          You received this message because you are subscribed to the Google Groups "vim_use" group.
                          To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@....
                          For more options, visit https://groups.google.com/groups/opt_out.
                        • Christian Wellenbrock
                          ... I agree, that sounds useful. -- -- You received this message from the vim_use maillist. Do not top-post! Type your reply below the text you are replying
                          Message 12 of 13 , Feb 7, 2014
                          • 0 Attachment
                            On Friday, February 7, 2014 7:07:50 PM UTC+1, David Fishburn wrote:
                            > ...
                            >  
                            >
                            > > FWIW I would like to be able to define text objects in terms of
                            > > 'syntax objects' (yes I just made that term up, I mean primarily
                            > > the piece of text seleced by a :syn match or :syn region as
                            >
                            > > identified by the syntax group it is connected with).
                            >
                            > ...That's actually an interesting idea. I'm not sure how useful it would be though. Looking at some local code files the regions with common syntax are usually strings, comments or single words. All of which can be operated on with default text objects.
                            >
                            >
                            >
                            >
                            > Do you see real world editing tasks where you would benefit from selecting all text inside the current syntax region?
                            >
                            >
                            > I think a simple case might be when you are editing a HTML file.
                            >
                            >
                            >
                            > You can embedded different syntax objects within it, javascript, perl, php, ...
                            >
                            >
                            > Some of the html syntax files do this already.  They can highlight Javascript as "javascript" and highlight the rest of the page as "html".
                            >
                            >
                            >
                            > So, I might like to highlight my "javascript" code using one of these text objects and hit = to format it.
                            >
                            >
                            > That was one of the first usages that came to mind to me.
                            >
                            >
                            >
                            > David
                            >  

                            I agree, that sounds useful.

                            --
                            --
                            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

                            ---
                            You received this message because you are subscribed to the Google Groups "vim_use" group.
                            To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@....
                            For more options, visit https://groups.google.com/groups/opt_out.
                          • BPJ
                            ... The one most on my mind was Markdown links and link references, which look like either of these: [link text](http://example.com) [link text][label] [link
                            Message 13 of 13 , Feb 7, 2014
                            • 0 Attachment
                              2014-02-07 19:07, David Fishburn skrev:
                              >>
                              >> ...
                              >>
                              >
                              >
                              >>> FWIW I would like to be able to define text objects in terms of
                              >>> 'syntax objects' (yes I just made that term up, I mean primarily
                              >>> the piece of text seleced by a :syn match or :syn region as
                              >>> identified by the syntax group it is connected with).
                              >>
                              > ...
                              >
                              >> That's actually an interesting idea. I'm not sure how useful it would be
                              >> though. Looking at some local code files the regions with common syntax are
                              >> usually strings, comments or single words. All of which can be operated on
                              >> with default text objects.
                              >>
                              >> Do you see real world editing tasks where you would benefit from selecting
                              >> all text inside the current syntax region?
                              >
                              >
                              > I think a simple case might be when you are editing a HTML file.
                              >
                              > You can embedded different syntax objects within it, javascript, perl, php,
                              > ...
                              >
                              > Some of the html syntax files do this already. They can highlight
                              > Javascript as "javascript" and highlight the rest of the page as "html".
                              >
                              > So, I might like to highlight my "javascript" code using one of these text
                              > objects and hit = to format it.
                              >
                              > That was one of the first usages that came to mind to me.

                              The one most on my mind was Markdown links and link references,
                              which look like
                              either of these:

                              [link text](http://example.com)

                              [link text][label]

                              [link text, also label][]

                              where the contents of at least the second bracket/paren pair is
                              itself hilighted with its own highlight group; I'd like to
                              operate on the reference as a whole (both bracket pairs with
                              their contents) even though they are two ] objects and even
                              though the cursor is located on the label. Another case is a
                              Pandoc markdown extension which I use more than is good for me
                              :-) the inline note, which looks like this

                              ^[note text]

                              which I'd like to capture from the caret to the right bracket.
                              Ideally also a way to jump to the beginning of the link/note text
                              from outside, jumping to the next note even if a link intervenes
                              or vice versa.

                              /bpj

                              --
                              --
                              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

                              ---
                              You received this message because you are subscribed to the Google Groups "vim_use" group.
                              To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@....
                              For more options, visit https://groups.google.com/groups/opt_out.
                            Your message has been successfully submitted and would be delivered to recipients shortly.