I use xubuntu 14.04, 64 bit. Every now and then, when I try to paste some text in xfce4-terminal, instead of the expected text to be pasted, it is surrounded by 0~ and 1~, such as:

0~mvn clean install1~

The text is supposed to be mvn clean install -- I verified this by pasting the content in various other applications (gnome-terminal, gedit and others). Every application pastes correctly the content, except xfce4-terminal. I couldn't find any references for this on the internet (unfortunately, it is hard to search for text with special characters on google.com...). Why does this happen?

  • How are you pasting? Middle click, or something else?
    – Celada
    Apr 15 '15 at 0:02
  • 3
    I've tried every method: middle click, right click and chose option paste, ctrl+shift+v. When the 0~ and 1~ characters appear, it does not matter which pasting method I use. Apr 15 '15 at 10:38

The issue is that your terminal is in bracketed paste mode, but doesn’t seem to support it properly. The issue was fixed in VTE, but xfce4-terminal is still using an old and unmaintained version of it.

You can try temporarily turning bracketed paste mode off by using:

printf "\e[?2004l"
  • 4
    If you can’t always reproduce it it might be that you were running some program that enabled bracketed paste mode and then it crashed, thus wasn’t able to disable it before exiting.
    – remmy
    Apr 16 '15 at 13:46
  • 6
    Awesome, thanks! I've been struggling with this issue for more than a year. Is it possible to disable this "bracketed paste mode" completely? BTW, who implements such crazy things? ;) Apr 13 '16 at 13:00
  • 4
    it depends on your terminal. And it is a really useful feature, since it lets applications know whether something was typed in or pasted. For one, weechat, an IRC program, uses it to ask if you want to send multi-line pastes, which it couldn't do without bracketed paste mode, since then there would be no way to know if the user typed the lines or not.
    – remmy
    May 4 '16 at 10:42
  • 1
    How can I find which program is messing with bracketed paste mode?
    – aviggiano
    Jul 12 '17 at 16:49
  • 3
    For distributions based on Ubuntu you can try to install patched version of 'vte' package from launchpad.net/~adrozdoff/+archive/ubuntu/vte Oct 21 '17 at 21:22

My issue was due to a badly-closed bash session. So running command reset in my terminal solved it immediately.

  • 2
    This worked for me.
    – AFP_555
    May 3 '18 at 22:54
  • And it worked for me!
    – tomd
    May 22 '18 at 1:29
  • Happened with Ubuntu 16.04, using terminator. reset worked! Jul 18 '18 at 18:58
  • My terminator was doing the same, also running Ubuntu 16.04. Running reset on my ssh connection fixed it. Nov 30 '18 at 19:23
  • 2
    Happened in Mac terminal for me. this fixed it
    – raghav710
    Aug 5 '20 at 17:10

I had the same issue, it occurs after I use vi.

Mine was resolved by adding set t_BE= to my .vimrc file.

For reference, this is what t_BE does:

t_BE enable bracketed paste mode

  • 8
    That was exactly the cause, thanks! In my case it started when I upgraded to VIM 8
    – rgerganov
    Jan 25 '18 at 15:21
  • 1
    could you please explain what set t_BE= does and why it solves the issue?
    – Tropilio
    May 17 '18 at 9:30

This behavior occurs when the terminal emulator is stuck in bracketed paste mode.

This typically happens when an application exits uncleanly (crashes or is buggy).

Another reason for the phenomenon to occur frequently is a bug in older versions of VTE (VTE is the terminal emulation widget under gnome-terminal and xfce4-terminal and many more) which is triggered by certain actions in certain utilities such as toggling the panels in Midnight Commander.

To see if this bug is fixed in the VTE-based terminal emulator you're running: Execute echo -ne '\e[>c', this will insert a few characters as if you typed them. If the middle number is 3602 or bigger, the aforementioned old VTE bug is no longer present for you. If the number is smaller than that, VTE is still affected and gets stuck in bracketed paste mode more often than it should.

To see if a certain terminal emulator is fixed in a certain Ubuntu distribution, check its dependencies on packages.ubuntu.com. libvte-2.91-0 is good. libvte-2.90-9 is only good if the actual version of that package is 0.36.2 or newer, and libvte9 is bad. In particular, xfce4-terminal is buggy in Xenial, and fixed in Zesty.


This may not apply directly to your problem, but I found this symptom to probably, in my case, be caused by my editor-of-choice 'mcedit' (Midnight Commander)

To alleviate the bug problem, I added the following function to my .bashrc file:

### vvv 'function mcedit' is a fix-up for the ~0/~1 paste problem
function mcedit() { command mcedit $@ ; printf '\e[?2004l' ; }

Then 'source .bashrc'

Now every time I execute 'mcedit', it automatically adds the 'printf "\e[?2004l"' when I close out to reset the "Bracketed Paste Mode"

Works for me, YMMV.

The same approach can be used with vi, vim, nano, or any other misbehaving program.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.