Ubuntu solution to the problem of vi editing error up and down turning into abcd

When using vi editing in Ubuntu, press up, down, left, and right to become ABCD

, if characters such as abcd appear when you press the up, down, left, and right keys in Vi, this may be because there is a problem with your terminal settings, causing Vi to fail to correctly parse the arrow keys. In the vi editor, the up, down, left and right keys change to ABCD, probably because vi compatibility mode is turned on. You can try the following solutions


In order to solve this problem, you can try the following methods:

  • method one:
    1. Enter at the command linesudo apt-get remove vim-common, uninstall vim tiny version.
    2. entersudo apt-get install vim, install vim full version.
  • Method Two:
    1. Enter at the command linesudo apt-get remove vim-common, uninstall vim tiny version.
    2. open a file/etc/vim/vimrc.tiny, change "set compatible" to "set nocompatible".
    3. Save the file and enter in the command linesource vimrc.tiny.
    4. Restart the computer.

If you still have problems, you can also try the following methods:

Press the Esc key in Vi, then enter: set nocompatible, press Enter and then press i to enter the editing mode to see if you can use the up, down, left, and right keys normally.

Confirm your terminal type and Vi's compatibility settings. Enter echo $TERM in the terminal to check the terminal type. If it is xterm-256color or similar, you can try to enter export TERM=xterm in the terminal and restart Vi. If you are using a macOS system, you can try entering export TERM=xterm-256color in the terminal.

Confirm that you have enabled application key mode for your terminal emulator. In Vi, press Esc and type: set t_k1=^[[A t_k2=^[[B t_k3=^[[C t_k4=^[[D. This will enable the arrow keys for Vi. If this command solves the problem, you can add it to your bashrc file to automatically enable it every time you start the terminal.

Or you can reinstall vim

Installing the vim full version Since Ubuntu is pre-installed with the tiny version, it will cause inconvenience. So we need to install the full version of vim. Uninstall the old version of vi first

sudo apt-get remove vim-common

Install the full version of vim:

sudo apt-get install vim

If you encounter the error "-bash: /usr/bin/vi: No such file or directory"

In the system, vi is a commonly used text editor. If you encounter "/bin/sh: /usr/bin/vi: No such file or directory" error in the terminal, it may be due to the following reasons:

  1. vi editor not installed: In some Linux distributions, vi editor may not be installed by default. You can solve this problem by installing vi package.
  2. Incorrect path: It may be that the vi editor path is incorrect, causing the system to be unable to find the vi command.
    To resolve this issue, you can try the following:
    Method 1: Install vi editor
  3. Open Terminal.
  4. Run the following command to update the package list (skip this step if it is already up to date):
    1. sudo apt update
  5. Install vi editor:
    1. sudo apt install vim
  6. After the installation is complete, reopen the terminal and try to use the vi command again.
    Method 2: Check the path of the vi command
  7. Run the following command in the terminal to check whether the path to the vi command exists:
    1. which vi

    If the output is empty, it means that the path to the vi command does not exist.

  8. If the path to the vi command does not exist, you can try adding the path to the vi command to your PATH environment variable. Open a terminal and run the following command to edit your shell configuration file (e.g. bashrc):
    1. nano ~/.bashrc
  9. In the opened file, add the following line (skip this step if it already exists):
    1. export PATH=$PATH:/usr/bin/
  10. After saving and closing the file, run the following command to make the configuration take effect:
    1. source ~/.bashrc
  11. Reopen the terminal and try using the vi command again.
    Through the above method, you should be able to solve the "/bin/sh: /usr/bin/vi: No such file or directory" error and be able to use the vi editor normally. Note that these methods work on Debian and Ubuntu-based Linux distributions. If you are using another distribution, please adjust the commands and configuration files accordingly.
5/5 - (1 vote)

Leave a Reply

Your email address will not be published. Required fields are marked *