Click here to Skip to main content
15,894,330 members
Articles / All Topics

vi or vim Using Backspace Inserts ^?

Rate me:
Please Sign up or sign in to vote.
5.00/5 (1 vote)
23 Aug 2017CPOL2 min read 5K  
vi or vim Using Backspace Inserts ^?

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:

Edit .kshrc

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:

vim insert mode

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:

Backspace inserts ^?

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”.

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
Image 5 Image 6

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer Taft College
United States United States
I’m a software developer. Currently I’m working at Taft College as a Programmer.

Comments and Discussions

 
-- There are no messages in this forum --