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
相关推荐
s***46983 小时前
linux 设置tomcat开机启动
linux·运维·tomcat
xu_yule3 小时前
网络和Linux网络-3(套接字编程)TCP网络通信代码
linux·网络·tcp/ip
HalvmånEver4 小时前
Linux:进程的切换与调度(进程四)
linux·运维·服务器
LCG元5 小时前
终端里的"黑客帝国":htop, glances, bpytop 系统监控工具横评
linux
L***B5685 小时前
如何安装linux版本的node.js
linux·运维·node.js
LCG元5 小时前
终极武器:用 systemd 管理你的自定义应用服务(附配置文件)
linux
脏脏a6 小时前
【Linux】Linux进程状态深度解析
linux·运维·服务器
凉晓风6 小时前
Linux中常见几种自启动方式的区别
linux·运维·服务器
LCG元6 小时前
考古利器:find 命令的高级用法,按时间、大小、内容精准查找
linux
U***74697 小时前
Linux(CentOS)安装 MySQL
linux·mysql·centos