Bug#504244: Vim script to turn on and use xterm bracketed paste mode

Josh Triplett josh at joshtriplett.org
Sat Feb 8 07:46:32 UTC 2014


On Wed, Dec 23, 2009 at 02:27:01AM -0800, Josh Triplett wrote:
> The following, added somewhere vim runs at startup, will use xterm's
> bracketed paste mode to make pasting automatically enable paste mode
> (and insert mode).  Also works fine in ~/.vimrc .
> 
> if &term == "xterm"
>     let &t_ti = &t_ti . "\e[?2004h"
>     let &t_te = "\e[?2004l" . &t_te
>     function XTermPasteBegin(ret)
>         set pastetoggle=<Esc>[201~
>         set paste
>         return a:ret
>     endfunction
>     map <expr> <Esc>[200~ XTermPasteBegin("i")
>     imap <expr> <Esc>[200~ XTermPasteBegin("")
> endif

I received a question via private email regarding the licensing of this
snippet, which hadn't occurred to me.  (The request was regarding the
use of this as the basis for implementing support for Emacs.)  I suppose
I'd originally figured that if vim wanted to incorporate it, it could do
so under the vim license.  However, given that (pleasantly unexpected)
request, I'll be more explicit, and more permissive:

Feel free to use this code under any of the vim license, the MIT
license, or the GPL version 2 or later, whatever's convenient for the
context you want to use it in.  (MIT is compatible with both of the
other two, but I'm mentioning them explicitly to avoid any need for a
prospective user to include the terms of the MIT license if dropping
this into a project under the vim license or the GPL.)

In my opinion, I'd also suggest that this code seems so short and so
directly based on the definition of bracketed paste mode that any
reimplementation for another editor (in another language and using
another editor's features in place of things like vim's paste mode)
would almost certainly be sufficiently different so as to no longer be a
derived work of the snippet above, and not subject to the above license
at all.

It's sad that this mail is longer than the snippet it references.

Hope that helps,
Josh Triplett



More information about the pkg-vim-maintainers mailing list