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 小时前
图数据库neoj4安装部署使用
linux·运维·数据库
做运维的阿瑞3 小时前
CentOS DNS故障排查完整解决方案:从症状到根因的系统化诊断
linux·运维·centos
QT 小鲜肉4 小时前
【个人成长笔记】在 Linux 系统下撰写老化测试脚本以实现自动压测效果(亲测有效)
linux·开发语言·笔记·单片机·压力测试
itachi-uchiha4 小时前
head和tail命令使用
linux·运维·服务器
馨谙5 小时前
SELinux 故障排除完全指南:从拒绝访问到快速修复
linux
凤凰战士芭比Q5 小时前
LNMP环境部署 KodBox私有云盘
linux·架构
南棱笑笑生6 小时前
20251106给荣品RD-RK3588-MID开发板跑Rockchip的原厂Android13系统时禁止锁屏+永不休眠
linux·运维·服务器·rockchip
赖small强6 小时前
Linux 优先级反转问题详解与处理方案
linux·优先级反转·优先级继承·缩短临界区
wdfk_prog6 小时前
[Linux]学习笔记系列 -- [kernel][time]timekeeping
linux·笔记·学习
yuanManGan6 小时前
走进Linux的世界:冯诺依曼体系结构
linux