Introduction
In my day to day job, I use Linux hosts and I always use the vim editor (In most Linux distros, vi is an alias for vim). When using PuTTY to connect to a Red Hat Enterprise Linux host, and then editing a file, after pressing the <–Backspace key on my keyboard, the editor inserts the characters ^? into the edited file. This has been very annoying, and I finally figured out a way to resolve this with a PuTTY configuration change. This is what this article is about.
The Problem
To edit a file, simply issue the command:
vi <filename>
Where <filename>
is the file you want to edit. Below is a screenshot of the vim editor editing the user’s Kern shell run control file:
Then to edit the file, change to “insert
” mode by pressing the “i
” key on your keyboard. You will see “– INSERT –
” on the very bottom line as per the following screenshot:
Now if I start to enter in a comment and then I try pressing backspace to try to delete the text that I’m inserting, you will see the ^?
characters being inserted as per the following screenshot:
This is the specific problem.
The Fix
To fix the problem, you’ll need to set the correct Backspace key mapping in PuTTY. Open the PuTTY Configuration app, and load a saved session. Then select “Terminal > Keyboard”. It will look like the following screenshot. You will need to select “Control-H”.
IMPORTANT: After selecting “Control-H”, you need to go back to “Session” and then click the “Save” button to save your changes, otherwise the change will not take effect permanently.
Now if you go into vim (or vi) and edit a file, when you use the Backspace key, you will no longer see the ^? character being inserted in your file.
Enjoy!
Tagged: PuTTY, vi, vim