In VI, when an arrow key is pressed, a character (e.g. “A“) is sent.

That usually happens when vi is running in a mode that doesn't understand your terminal's arrow key escape sequences.

Here's why:

  • Arrow keys don't send a single character; they send an escape sequence (for example, the Up arrow sends ESC [ A).

  • If vi (or more commonly the very old ex/vi implementation , not vim) doesn't recognize these escape sequences, it just displays the trailing characters like A, B, C, D (or sometimes M) instead of moving the cursor.

Common reasons

  1. You're actually running vi, not vim .

    Some minimal Linux/Unix systems only ship with the original BSD vi, which lacks proper arrow key support.

  2. Terminal type mismatch .

    If your $TERM environment variable is wrong (e.g., set to dumb instead of xterm-256color), vi doesn't know how to interpret escape sequences.

  3. Insert mode vs command mode.

    • In command mode, arrows usually work.

    • In insert mode , some old vi versions don't handle them and show A, B, etc.

Fixes

  • Use vim instead of vi:

    bash 复制代码
    sudo apt install vim      # Ubuntu/Debian
    sudo yum install vim      # RHEL/CentOS
  • Check your terminal type:

    bash 复制代码
    echo $TERM

    If it says dumb, set it properly:

    bash 复制代码
    export TERM=xterm-256color
相关推荐
Suger9993 小时前
centos网络打流测试
linux·网络·centos
小何好运暴富开心幸福4 小时前
操作系统之初识Linux
linux·运维·服务器·bash
こ进制掌控者5 小时前
Ubuntu server 24.04.3 设置静态IP
linux·tcp/ip·ubuntu
泡沫冰@5 小时前
shell编程:sed - 流编辑器(5)
linux
xiaguangbo6 小时前
rust slint android 安卓
android·linux·rust
晓梦初醒p6 小时前
finalshell 连接服务器报错channel is not opened
linux·运维·服务器
conkl7 小时前
在ARM64 Ubuntu 20.04上部署Mailu邮件系统:深度排查Docker Bridge网络通信失败问题
linux·ubuntu·docker
Code Warrior7 小时前
【Linux】基础IO(2)
linux
你什么冠军?7 小时前
linux入门4.5(NFS服务器和iSCSI服务器)
linux·运维·服务器