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
相关推荐
你有按下913的勇气吗1 分钟前
【Agent,RAG,Transform】
linux·运维·服务器
ken22324 分钟前
linux OS : apt update 使用代理与环境变量
linux
小义_14 分钟前
随笔 1(Linux)
linux·运维·服务器·网络·云原生·红帽
Larry_Yanan27 分钟前
Qt网络开发之基于 QWebEngine 实现简易内嵌浏览器
linux·开发语言·网络·c++·笔记·qt·学习
AI+程序员在路上1 小时前
CAN 总线与 Linux SocketCAN C 语言测试程序
linux·c语言·网络
Predestination王瀞潞1 小时前
4.3.3 存储->微软文件系统标准(微软,自有技术标准):VFAT(Virtual File Allocation Table)虚拟文件分配表系统
linux·microsoft·vfat
HalvmånEver1 小时前
Linux:socket套接字编程的基础概念
linux·运维·服务器
IMPYLH2 小时前
Linux 的 cp 命令
linux·运维·服务器
@syh.2 小时前
【linux】多线程
linux
RisunJan2 小时前
Linux命令-man(查看Linux中的指令帮助)
linux·运维·服务器