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
相关推荐
枳实-叶7 分钟前
【Linux驱动开发】第10天:设备树零基础入门——DTS/DTB/DTC全解+编译流程
linux·运维·驱动开发
枳实-叶11 分钟前
【Linux驱动开发】第11天:设备树(Device Tree)超详细全解:从诞生背景到工作原理
linux·运维·驱动开发
IceSugarJJ12 分钟前
Windows下VSCode+ WSL项目启动流程
linux·windows·vscode·ubuntu·wsl
Bert.Cai25 分钟前
Linux shift命令详解
linux·运维·服务器
cui_ruicheng28 分钟前
Linux网络编程(六):UDP聊天室与线程池
linux·服务器·网络·udp
Yeats_Liao32 分钟前
物联网接入层技术剖析(一):从select到epoll
java·linux·后端·物联网·struts
一只小逸白33 分钟前
LeetCode Go 常用函数速查表
linux·leetcode·golang
文青小兵33 分钟前
云计算Linux——数据库MySQL读写分离、数据库备份、恢复(十八)
linux·运维·服务器·数据库·mysql·云计算
Ghost Face...38 分钟前
PCI总线配置核心实现与架构解析
linux·运维·架构
曾阿伦1 小时前
Linux 系统资源查看命令大全
linux·运维·服务器