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
相关推荐
qq_857305819几秒前
ubuntu 22 源码安装bochs
linux·运维·ubuntu
Zhu7581 分钟前
【软件更新】在Ubuntu24 LTS中更新openssl到指定版本,例如openssl3.5.6 LTS
linux·ssh·ssl
ALINX技术博客2 分钟前
【黑金云课堂】VMware Ubuntu 开发环境安装教程
linux·fpga开发·fpga
charlie1145141915 分钟前
嵌入式Linux模块开发——struct module 深度解析:内核模块的核心数据结构
linux·开发语言·数据结构·c
刘某的Cloud11 分钟前
svc中外部流量访问限制
linux·运维·docker·kubernetes·service
code monkey.14 分钟前
【寻找Linux的奥秘】Linux 基础 IO 全解析:从 C 库到内核,吃透文件操作的底层逻辑
linux·c语言·基础io
ZzzZZzzzZZZzzzz…24 分钟前
MySQL还原备份方法3----gtid
linux·运维·数据库·mysql·还原备份
.select.27 分钟前
TCP 6(重传机制)
linux·服务器·tcp/ip
大卡片33 分钟前
IO缓存区
linux·运维·缓存
somi738 分钟前
ARM-驱动-03 Linux 字符设备驱动开发
linux·arm开发·驱动开发·自用