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
相关推荐
躺不平的理查德2 小时前
Nginx与Ajax 备忘录
linux·运维·服务器
惜离殇2 小时前
从零开始的敲代码生活--Linux应用软件(文件操作基础2)
linux·文件io·目录io
Sunqk56652 小时前
将开发板串口连接到Ubuntu后未找到对应的设备文件?
linux·运维·ubuntu
Sophnet云平台2 小时前
MCP与A2A双协议解析:2026年Agent互操作的技术选型
linux·服务器·网络·上下文·mcp·大模型测评·sophnet
晚风叙码2 小时前
Linux(二)权限问题
linux·服务器
BI专家之路4 小时前
安装linux/hadoop/jdk/hive
linux·hive·hadoop
GeW17 小时前
超详细!RHCE10版通用备考策略,内含评分细则解读
linux
用户0413284651317 小时前
Linux 服务开机自启动怎么配置?systemctl enable 原理详解
linux
草莓熊Lotso1 天前
【Redis 初阶】Set 类型深度解析:去重集合的运算能力与实战场景
linux·网络·数据库·windows·redis·tcp/ip·缓存
张文君1 天前
ubuntu26.04坏道坏块分区隔离急速版260831-V0.12
linux·python