GNOME Bugzilla – Bug 605299
Please support xterm bracketed paste mode
Last modified: 2009-12-28 02:23:20 UTC
Xterm has a bracketed paste mode, in which it will send \e[200~ before pasted text and \e[201~ after pasted text. This allows programs to distinguish pasted text from typed text. For example, the following vim script will make vim automatically use paste mode for pastes, avoiding unwanted duplicate indentation or formatting: 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 xterm itself supports bracketed paste mode, but vte does not, and thus neither do gnome-terminal and other terminals built on vte. http://invisible-island.net/xterm/ctlseqs/ctlseqs.html documents the details of bracketed paste mode. \e[?2004h turns on bracketed paste mode, and \e[?2004l turns it off.
Created attachment 150437 [details] [review] Patch implementing XTerm's bracketed paste mode in vte. I've attached a git patch against current vte HEAD (7f017f27ff254995c1ad4fbe4947b929c4c6046f) that implements XTerm's bracketed paste mode. (Please apply with "git am 0001-Bug-605299-Please-support-xterm-bracketed-paste-mode.patch".) I tested this patch both with the "vte" test program and by running gnome-terminal with LD_LIBRARY_PATH pointing at new libvte (and --disable-factory so it would actually run a new instance with the new libvte). In both cases, bracketed paste mode worked exactly as specified.
Committed. Thanks!