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
相关推荐
报错小能手5 小时前
linux学习笔记(35)C语言连接mysql
linux·笔记·学习
心一信息5 小时前
grafana及zabbix在linux上的部署
linux·zabbix·grafana
deng-c-f5 小时前
Linux C/C++ 学习日记(27):KCP协议(三):源码分析与使用示例
linux·服务器·网络·c++·网络编程·kcp
wangjialelele6 小时前
端口号、常见协议和套接字
linux·运维·服务器·c语言·网络
蜜蜜不吃糖6 小时前
ESXI主机重置带外密码
linux·运维·服务器
ZhiqianXia6 小时前
Linux SysRq
linux
Zach_yuan6 小时前
版本控制器Git
linux·git
Dobby_057 小时前
【Go】C++ 转 Go 第(一)天:环境搭建 Windows + VSCode 远程连接 Linux
linux·运维·c++·vscode·golang
赖small强7 小时前
Linux 页缓存(Page Cache)与回写(Writeback)机制详解
linux·页缓存(page cache)·回写(writeback)·脏页
蓝冰印8 小时前
HarmonyOS Next 快速参考手册
linux·ubuntu·harmonyos