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 分钟前
Linux系统——库的原理与制作之ELF文件的形成与加载的过程(下)
linux·动静态库
CrazyMo_11 分钟前
鸿蒙高级——内存专用之linux-reserve-memory 方案简介
linux·运维·服务器
灯澜忆梦30 分钟前
【Linux】#5 | 文件与目录基础操作命令
java·linux·运维
wuminyu1 小时前
stackChunkOop内部结构与GC屏障的配合工作原理剖析
java·linux·c语言·jvm·c++
青衫客361 小时前
从网卡到 Socket:再探 Linux 网络协议栈与 iptables 数据包处理流程
linux·网络·网络协议
承渊政道1 小时前
Linux网络学习【TCP Socket编程实战:connect的断线重连与客户端访问Linux验证】
linux·网络·学习·ubuntu·tcp·socket编程
sunoo-2291 小时前
嵌入式Linux驱动学习笔记(第3-6天):从misc封装、platform总线到设备树、中断与单总线外设实战
linux·arm开发·驱动开发·笔记·单片机·学习
雪落漂泊1 小时前
Linux基础开发工具(一)软件包管理器与Vim编辑器篇
linux·运维·服务器
崽崽..1 小时前
【Linux】网络编程的调试工具以及连接失败的具体排查方法
linux·网络
承渊政道1 小时前
CentOS 7单机部署Elasticsearch 7.17.29:从启动报错、CRUD验证到固定公网地址的完整过程
linux·elasticsearch·centos·内网穿透·cpolar·单机部署