So this just happened as I was writing some C code in vim in Ubuntu 16.04's terminal.

Any time I try to enter a right bracket, the terminal window shows me a '7'. In addition, pressing the '7' key enters a down arrow character (a unicode character I think).


fprintf(stdout, "%s\n", argv[17);

Weirdly, pressing Shift-] results in a '}' as expected, and the other number keys show the corresponding number correctly.

Thinking it was an issue in vim, I tried opening the file in emacs and saw the same thing.

And when I tried compiling the file with gcc, the compiler output had the same weird encoding issue.

I tried to ssh to a remote server and the same thing happened, so I'm pretty sure the problem is with how my terminal is presenting characters.

What's going on and how do I fix it?

Edit: Issue resolved thanks to the tip to use the reset command. Everything works fine after restarting my terminal. I had been working with binary data which seems to be the cause of this problem.

  • Does the keyboard work properly in a gui? Have you tried reset like here? stackoverflow.com/a/121299
    – brndn2k
    Mar 10, 2017 at 5:49
  • @brndn2k Yeah it works properly in programs like internet browsers, though not if I used gedit to open a C file. That works the same way as emacs and vim. But! That link definitely did the trick. I closed all my open terminals and used reset and everything's back to normal. I had been working with binary data so that seems to be the explanation for why things were changed so randomly as was mentioned in the link.
    – sn9
    Mar 10, 2017 at 8:12
  • What do you mean the compiler had the same issue? Is the character being entered a 7 or something else? Also, is this a laptop with a numpad in the main keyboard and you have numlock on, by any chance? Mar 11, 2017 at 0:02
  • @terdon I meant that the compiler output had the same issue, which was something I noticed after discovering my text editors had the issue. This wasn't surprising since it was an issue with the terminal from which I was viewing everything. (Although I'm still not clear on why Emacs and Gedit opened in their GUI forms had the same issue.) It was on a Lenovo laptop, but I wasn't using the numberpad. brndn2k's link resolved the issue.
    – sn9
    Mar 13, 2017 at 4:27
  • @sn9 oh, well, all's well tat ends well. It would be great if you could post an answer explaining what you did to solve it and then accept the answer so the question can be marked as solved. Mar 13, 2017 at 9:12

1 Answer 1


Thanks to the link posted by user brndn2k, I was able to resolve the issue.

I had been working with binary data and that must have been the culprit, as mentioned in the link.

Using the reset command and restarting my terminals returned the terminal to normal character encoding.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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