Solution to the problem that up, down, left, and right become abcd in vi editing error in Ubuntu

When using vi to edit in Ubuntu, pressing up, down, left, and right will change to ABCD

If you press the up, down, left, and right keys in Vi but characters such as abcd appear, it may be because your terminal settings are wrong, causing Vi to be unable to correctly parse the arrow keys. In the vi editor, the up, down, left, and right keys become ABCD, which may be because vi compatibility mode is turned on. You can try the following methods to solve it

Solution to Ubuntu's vi editing when up, down, left, and right become abcd -1

To fix this, you can try a few things:

  • Method 1:
    1. Type in the command linesudo apt-get remove vim-common, uninstall the vim tiny version.
    2. entersudo apt-get install vim, install the full version of vim.
  • Method 2:
    1. Type in the command linesudo apt-get remove vim-common, uninstall the vim tiny version.
    2. Opening a file/etc/vim/vimrc.tiny, change "set compatible" to "set nocompatible".
    3. Save the file and enter it in the command linesource vimrc.tiny.
    4. Restart your computer.

If you still have problems, you can 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 compatibility settings. Enter echo $TERM in the terminal to check the terminal type. If it is xterm-256color or similar, you can try entering export TERM=xterm in the terminal and restarting Vi. If you are using macOS, you can try entering export TERM=xterm-256color in the terminal.

Verify that you have application keys mode enabled for your terminal emulator. Press Esc in Vi and then 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 does the trick, you can add it to your bashrc file so that it is automatically enabled every time you start a terminal.

Or you can reinstall vim

Install vim full version Since Ubuntu pre-installs the tiny version, it will cause inconvenience in use. So we need to install the full version of vim. First uninstall the old version of vim

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 Linux systems, vi is a commonly used text editor. If you encounter the error "/bin/sh: /usr/bin/vi: No such file or directory" 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 fix this issue by installing the vi package.
  2. Incorrect path: The system may be unable to find the vi command because the path of the vi editor is incorrect.
    To fix this, you can try the following:
    Method 1: Install the 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 the 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 of the vi command exists:
    1. which vi

    If the output is empty, it means 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 (such as 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 to use the vi command again.
    With the above methods, you should be able to resolve the “/bin/sh: /usr/bin/vi: No such file or directory” error and be able to use the vi editor normally. Please note that these methods are applicable to Debian and Ubuntu based Linux distributions. If you are using another distribution, please adjust the commands and configuration files accordingly.
3/5 - (2 votes)

Leave a Reply

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