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

Bracketed paste for terminal vim

Expand Messages
  • Bruno Sutic
    Hello! I got really excited about one discovery, so I d like to start a discussion and see if there is a possible fit into vim s feature roadmap. So,
    Message 1 of 5 , Jul 11, 2014
      Hello!

      I got really excited about one discovery, so I'd like to start a discussion and see if there is a possible fit into vim's feature roadmap.

      So, apparently all modern terminals have a feature to tell programs when something is pasted.
      Terminal does this by wrapping the paste content with sequences \e[200~ and \e[201~.

      Because of this, terminal programs (specifically vim) *could* tell a difference when something is typed vs pasted.
      This is nicely explained in the blog article here: http://cirw.in/blog/bracketed-paste

      And this is not just theory - the same guy wrote a small plugin that enables this for vim, link: https://github.com/ConradIrwin/vim-bracketed-paste (it's less than 30 lines of viml)

      I tried the plugin and it works great! (I'm on OS X, Terminal.app)
      The punch line is: as a terminal vim user, I don't have to use `:set paste` ever again!

      Now, what do you think: does this feature belong in the "plugin domain" or should it eventually be part of vim?

      I'm just a user, so I couldn't help with any of that, but I like the feature so much - maybe my enthusiasm will infect someone else! :)

      Bruno

      --
      --
      You received this message from the "vim_dev" 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_dev" group.
      To unsubscribe from this group and stop receiving emails from it, send an email to vim_dev+unsubscribe@....
      For more options, visit https://groups.google.com/d/optout.
    • Bram Moolenaar
      ... Sounds useful. Since what version of xterm and screen is this supported? I suspect older versions do not support it. -- BEDEVERE: Look! It s the old man
      Message 2 of 5 , Jul 11, 2014
        Bruno Sutic wrote:

        > I got really excited about one discovery, so I'd like to start a
        > discussion and see if there is a possible fit into vim's feature
        > roadmap.
        >
        > So, apparently all modern terminals have a feature to tell programs
        > when something is pasted.
        > Terminal does this by wrapping the paste content with sequences
        > \e[200~ and \e[201~.
        >
        > Because of this, terminal programs (specifically vim) *could* tell a
        > difference when something is typed vs pasted. This is nicely
        > explained in the blog article here:
        > http://cirw.in/blog/bracketed-paste
        >
        > And this is not just theory - the same guy wrote a small plugin that
        > enables this for vim, link:
        > https://github.com/ConradIrwin/vim-bracketed-paste (it's less than 30
        > lines of viml)
        >
        > I tried the plugin and it works great! (I'm on OS X, Terminal.app)
        > The punch line is: as a terminal vim user, I don't have to use `:set
        > paste` ever again!
        >
        > Now, what do you think: does this feature belong in the "plugin
        > domain" or should it eventually be part of vim?
        >
        > I'm just a user, so I couldn't help with any of that, but I like the
        > feature so much - maybe my enthusiasm will infect someone else! :)

        Sounds useful.

        Since what version of xterm and screen is this supported? I suspect
        older versions do not support it.

        --
        BEDEVERE: Look! It's the old man from scene 24 - what's he Doing here?
        ARTHUR: He is the keeper of the Bridge. He asks each traveler five
        questions ...
        GALAHAD: Three questions.
        "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD

        /// Bram Moolenaar -- Bram@... -- http://www.Moolenaar.net \\\
        /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
        \\\ an exciting new programming language -- http://www.Zimbu.org ///
        \\\ help me help AIDS victims -- http://ICCF-Holland.org ///

        --
        --
        You received this message from the "vim_dev" 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_dev" group.
        To unsubscribe from this group and stop receiving emails from it, send an email to vim_dev+unsubscribe@....
        For more options, visit https://groups.google.com/d/optout.
      • Bruno Sutic
        ... Hi Bram, glad you think it s useful. So I just googled it: it turns out this is available in xterm for years. Here s the blog post from 2009 showing how to
        Message 3 of 5 , Jul 11, 2014
          On Friday, July 11, 2014 11:35:24 PM UTC+2, Bram Moolenaar wrote:
          > Bruno Sutic wrote:
          >
          >
          >
          > > I got really excited about one discovery, so I'd like to start a
          >
          > > discussion and see if there is a possible fit into vim's feature
          >
          > > roadmap.
          >
          > >
          >
          > > So, apparently all modern terminals have a feature to tell programs
          >
          > > when something is pasted.
          >
          > > Terminal does this by wrapping the paste content with sequences
          >
          > > \e[200~ and \e[201~.
          >
          > >
          >
          > > Because of this, terminal programs (specifically vim) *could* tell a
          >
          > > difference when something is typed vs pasted. This is nicely
          >
          > > explained in the blog article here:
          >
          > > http://cirw.in/blog/bracketed-paste
          >
          > >
          >
          > > And this is not just theory - the same guy wrote a small plugin that
          >
          > > enables this for vim, link:
          >
          > > https://github.com/ConradIrwin/vim-bracketed-paste (it's less than 30
          >
          > > lines of viml)
          >
          > >
          >
          > > I tried the plugin and it works great! (I'm on OS X, Terminal.app)
          >
          > > The punch line is: as a terminal vim user, I don't have to use `:set
          >
          > > paste` ever again!
          >
          > >
          >
          > > Now, what do you think: does this feature belong in the "plugin
          >
          > > domain" or should it eventually be part of vim?
          >
          > >
          >
          > > I'm just a user, so I couldn't help with any of that, but I like the
          >
          > > feature so much - maybe my enthusiasm will infect someone else! :)
          >
          >
          >
          > Sounds useful.
          >
          >
          >
          > Since what version of xterm and screen is this supported? I suspect
          >
          > older versions do not support it.
          >
          >
          >
          > --
          >
          > BEDEVERE: Look! It's the old man from scene 24 - what's he Doing here?
          >
          > ARTHUR: He is the keeper of the Bridge. He asks each traveler five
          >
          > questions ...
          >
          > GALAHAD: Three questions.
          >
          > "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD
          >
          >
          >
          > /// Bram Moolenaar -- Bram@... -- http://www.Moolenaar.net \\\
          >
          > /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
          >
          > \\\ an exciting new programming language -- http://www.Zimbu.org ///
          >
          > \\\ help me help AIDS victims -- http://ICCF-Holland.org ///

          Hi Bram,
          glad you think it's useful.

          So I just googled it:
          it turns out this is available in xterm for years. Here's the blog post from 2009 showing how to make it work with vim and xterm:
          http://help.lockergnome.com/linux/Bug-504244-Vim-script-turn-xterm-bracketed-paste-mode--ftopict511918.html
          I found other online resources mentioning this in 2010, 2011. But the above link is the earliest.

          About screen - here's the patch from March 2013, so I guess it's been added there just recently:
          https://lists.gnu.org/archive/html/screen-devel/2013-03/msg00000.html

          --
          --
          You received this message from the "vim_dev" 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_dev" group.
          To unsubscribe from this group and stop receiving emails from it, send an email to vim_dev+unsubscribe@....
          For more options, visit https://groups.google.com/d/optout.
        • Paul "LeoNerd" Evans
          On Fri, 11 Jul 2014 23:35:15 +0200 ... It ultimately doesn t really matter. You send DECSM 2000 to ask for it to be enabled. Either that works and you now get
          Message 4 of 5 , Jul 14, 2014
            On Fri, 11 Jul 2014 23:35:15 +0200
            Bram Moolenaar <Bram@...> wrote:

            > Since what version of xterm and screen is this supported? I suspect
            > older versions do not support it.

            It ultimately doesn't really matter. You send DECSM 2000 to ask for it
            to be enabled. Either that works and you now get the extra keys, or you
            don't, and you don't. Have the incoming code cope with the received
            keys regardless, then it's just an optimisation.

            --
            Paul "LeoNerd" Evans

            leonerd@...
            http://www.leonerd.org.uk/ | https://metacpan.org/author/PEVANS
          • Bram Moolenaar
            ... I rather stay on the safe side and only send an escape sequence when it would do something useful. Keep in mind that whenever you run a shell it has to be
            Message 5 of 5 , Jul 14, 2014
              Paul Evans wrote:

              > On Fri, 11 Jul 2014 23:35:15 +0200
              > Bram Moolenaar <Bram@...> wrote:
              >
              > > Since what version of xterm and screen is this supported? I suspect
              > > older versions do not support it.
              >
              > It ultimately doesn't really matter. You send DECSM 2000 to ask for it
              > to be enabled. Either that works and you now get the extra keys, or you
              > don't, and you don't. Have the incoming code cope with the received
              > keys regardless, then it's just an optimisation.

              I rather stay on the safe side and only send an escape sequence when it
              would do something useful. Keep in mind that whenever you run a shell
              it has to be disabled. And also on exit, of course.

              Simplest would be to recognize the xterm version being above a certain
              level. I don't know how to check that for screen.

              --
              Yesterday, all my deadlines seemed so far away
              now it looks as though it's freeze in four days
              oh I believe in cvs..
              [ CVS log "Beatles style" for FreeBSD ports/INDEX, Satoshi Asami ]

              /// Bram Moolenaar -- Bram@... -- http://www.Moolenaar.net \\\
              /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
              \\\ an exciting new programming language -- http://www.Zimbu.org ///
              \\\ help me help AIDS victims -- http://ICCF-Holland.org ///

              --
              --
              You received this message from the "vim_dev" 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_dev" group.
              To unsubscribe from this group and stop receiving emails from it, send an email to vim_dev+unsubscribe@....
              For more options, visit https://groups.google.com/d/optout.
            Your message has been successfully submitted and would be delivered to recipients shortly.