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
相关推荐
二宝哥1 小时前
CentOS 7.9 离线安装 Nginx 并配置openssl1.1.1
linux·nginx·centos
程序员老陆1 小时前
说一说FFmpeg6在Linux平台的编译
linux·运维·服务器·ffmpeg
IT摆渡者2 小时前
VM EXSI7.0存储硬盘故障处理
大数据·linux·github
赵民勇2 小时前
systemd-cgtop命令详解
linux·运维
hhwyqwqhhwy3 小时前
Ubuntu22.04 安装vitis
linux
刚入门的大一新生3 小时前
Linux-Linux第一个系统程序-进度条
linux·运维·服务器
wuminyu3 小时前
JDK21解决虚拟线程IO阻塞原理剖析
java·linux·c语言·jvm·c++
茫忙然4 小时前
Linux提权辅助查询工具——BinLens的安装和使用
linux·提权·binlens
FlightYe4 小时前
linux系统编程(八):阻塞与非阻塞IO对比
android·linux·运维·服务器·github·vim
雾时之林5 小时前
Linux---计算机网络常见面试题
linux·运维·计算机网络