{"id":2079,"date":"2018-09-13T22:16:57","date_gmt":"2018-09-14T02:16:57","guid":{"rendered":"https:\/\/blog.jonesling.us\/?p=2079"},"modified":"2018-09-13T22:17:08","modified_gmt":"2018-09-14T02:17:08","slug":"vim-screen-and-bracketed-paste-mode","status":"publish","type":"post","link":"https:\/\/blog.jonesling.us\/?p=2079","title":{"rendered":"vim, screen, and bracketed paste mode"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">A little while back an update was introduced, somewhere, that has been driving me nuts.\u00a0 I didn&#8217;t record exactly when it happened or what changed.\u00a0 I suppose it doesn&#8217;t matter now.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The behavior wasn&#8217;t easy to pin down at first since it was the confluence of several things: 1) pasting 2) into vim while 3) using a non-xterm terminal like mate-terminal and 4) inside a screen session.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The behavior exhibits in several ways:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>Pastes appear to be incomplete, or (more correctly) some number of characters at the beginning of the paste go &#8220;missing&#8221; and actually become commands to vim<br\/><\/li><li>Pastes are complete but they&#8217;re bracketed with \\e[200~content\\e[201~<ul><li>some people report 0~content1~ instead, but it appears to be the same phenomenon<br\/><\/li><\/ul><\/li><\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">What&#8217;s going on?\u00a0 It&#8217;s a feature called &#8220;bracketed paste mode&#8221;.\u00a0 You can google it read up on it, it has some utility.\u00a0 As far as I can tell it&#8217;s related to readline.\u00a0 But more importantly, there is a fix.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Add this to your ~\/.vimrc:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">\" fix bracketed paste mode\nif &amp;term =~ \"screen\"\n  let &amp;t_BE = \"\\e[?2004h\"\n  let &amp;t_BD = \"\\e[?2004l\"\n  exec \"set t_PS=\\e[200~\"\n  exec \"set t_PE=\\e[201~\"\nendif<br\/><br\/>source: <a href=\"https:\/\/vimhelp.appspot.com\/term.txt.html#xterm-bracketed-paste\">https:\/\/vimhelp.appspot.com\/term.txt.html#xterm-bracketed-paste<\/a><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n","protected":false},"excerpt":{"rendered":"<p>A little while back an update was introduced, somewhere, that has been driving me nuts.\u00a0 I didn&#8217;t record exactly when it happened or what changed.\u00a0 I suppose it doesn&#8217;t matter now. The behavior wasn&#8217;t easy to pin down at first since it was the confluence of several things: 1) pasting 2) into vim while 3) &hellip; <a href=\"https:\/\/blog.jonesling.us\/?p=2079\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;vim, screen, and bracketed paste mode&#8221;<\/span><\/a><\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_crdt_document":"","wprm-recipe-roundup-name":"","wprm-recipe-roundup-description":"","advanced_seo_description":"","jetpack_seo_html_title":"","jetpack_seo_noindex":false,"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[9],"tags":[83,456,455,94,457],"class_list":["post-2079","post","type-post","status-publish","format-standard","hentry","category-linux","tag-linux","tag-readline","tag-screen","tag-vim","tag-xterm"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p4o3FW-xx","jetpack-related-posts":[],"jetpack_likes_enabled":true,"_links":{"self":[{"href":"https:\/\/blog.jonesling.us\/index.php?rest_route=\/wp\/v2\/posts\/2079","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.jonesling.us\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.jonesling.us\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.jonesling.us\/index.php?rest_route=\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.jonesling.us\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2079"}],"version-history":[{"count":1,"href":"https:\/\/blog.jonesling.us\/index.php?rest_route=\/wp\/v2\/posts\/2079\/revisions"}],"predecessor-version":[{"id":2080,"href":"https:\/\/blog.jonesling.us\/index.php?rest_route=\/wp\/v2\/posts\/2079\/revisions\/2080"}],"wp:attachment":[{"href":"https:\/\/blog.jonesling.us\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2079"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.jonesling.us\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2079"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.jonesling.us\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2079"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}