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
相关推荐
坐怀不乱杯魂3 分钟前
Linux网络 - 网络层
linux·服务器·网络
j_xxx404_5 分钟前
Linux:命令行参数与环境变量
linux·运维·服务器
j_xxx404_13 分钟前
Linux:进程虚拟地址空间|虚拟内存管理
linux·运维·服务器
江畔何人初24 分钟前
pod的定义以及创建过程
linux·运维·云原生
德尔塔大雨淋29 分钟前
VLLM 中的module PASS 和FUN PASS
linux·服务器·vllm
末日汐39 分钟前
linux线程
linux·运维
玉梅小洋1 小时前
CentOS :yum源配置及验证指南
linux·运维·centos·yum
UP_Continue1 小时前
Linux--进程控制
linux·运维·服务器
请输入蚊子1 小时前
«操作系统真像还原» 第二章 编写MBR主引导记录
linux·汇编·操作系统·bochs·操作系统真像还原
188号安全攻城狮2 小时前
【PWN】HappyNewYearCTF_8_ret2csu
linux·汇编·安全·网络安全·系统安全