busywait
Posts: 64
Joined: Sat May 09, 2020 10:48 pm
Location: Southampton, UK

Buster/Debian vi/vim cursor key misconfiguration and workaround

Thu May 21, 2020 2:35 pm

Using the insert mode in vi, when I try to navigate text using the cursor (arrow) keys my cursor jumps down a line and unwanted characters (A, B, C, D) are entered into my text. Similar problems using the Home/End keys.

This happens in the default desktop xterm (keyboard and monitor plugged directly into my Pi 4), or over SSH. This doesn't happen logged in to the TTY1-6 Consoles that I see when I press Ctrl+Alt+F1-6.

Steps to reproduce:
- fresh Rapsbian Buster full image install with the vim-tiny package, no other vim packages, configure with GB or UK locales
- boot to desktop
- start LXPanel (default terminal icon on the top panel), or ssh to login to the Pi
- from the command line, type vi
- in vi, type i (to enter insert mode)
- type a few carriage returns
- hit the up arrow

Expected behaviour
- cursor moves up

Observed behaviour
- The letter A appears

Workaround
- Option 1: Copy the example vimrc in to your home directory, and restart vi

Code: Select all

cp /etc/vim/vimrc ~/.vimrc
- Option 2: Install a more complete version of vim, eg

Code: Select all

sudo apt install vim
The version of vi that I am using is /usr/bin/vim.tiny from the default vim-tiny package, and there are no other vim packages installed when I see this problem. If I do install the full vim package alongside vim-tiny then the "vim.tiny" binary starts to work correctly too.

Code: Select all

pi@raspi4:~ $ dpkg -S $(realpath $(which vi))
vim-tiny: /usr/bin/vim.tiny
Related info that I don't think quite describes what's happening:
https://unix.stackexchange.com/question ... -vim-vimrc
(I can't find any default.vim file in Raspian Buster when I only have vim.tiny installed)

Is it helpful and possible for me to create an Issue for this sort of thing somewhere?
Last edited by busywait on Fri May 22, 2020 8:55 pm, edited 4 times in total.

User avatar
kerry_s
Posts: 976
Joined: Thu Jan 30, 2020 7:14 pm

Re: Buster/Debian vi/vim cursor key misconfiguration and workaround

Thu May 21, 2020 5:12 pm

who navigates in insert mode? :roll:

bls
Posts: 718
Joined: Mon Oct 22, 2018 11:25 pm
Location: Seattle, WA
Contact: Twitter

Re: Buster/Debian vi/vim cursor key misconfiguration and workaround

Thu May 21, 2020 5:22 pm

Just tried this on an xterm connected to a Pi4, with Buster 2020-02-13 Lite and the same version of vim as you, and did not see the behavior you're reporting. Possibly a termcap issue? What are the contents of your /etc/default/keyboard?
Pi tools:
Easily and quickly build customized-just-for-you SD Cards: https://github.com/gitbls/sdm
Free your network from your router's DHCP/DNS:https://github.com/gitbls/ndm
Easy strongSwan VPN installer/manager: https://github.com/gitbls/pistrong
Lightweight Virtual VNC Config: https://github.com/gitbls/RPiVNCHowTo

busywait
Posts: 64
Joined: Sat May 09, 2020 10:48 pm
Location: Southampton, UK

Re: Buster/Debian vi/vim cursor key misconfiguration and workaround

Thu May 21, 2020 6:31 pm

bls wrote:
Thu May 21, 2020 5:22 pm
Just tried this on an xterm connected to a Pi4, with Buster 2020-02-13 Lite and the same version of vim as you, and did not see the behavior you're reporting. Possibly a termcap issue? What are the contents of your /etc/default/keyboard?

Code: Select all

pi@raspi4:~ $ cat /etc/default/keyboard
# KEYBOARD CONFIGURATION FILE

# Consult the keyboard(5) manual page.

XKBMODEL="pc105"
XKBLAYOUT="gb"
XKBVARIANT=""
XKBOPTIONS=""

BACKSPACE="guess"

kerry_s wrote:
Thu May 21, 2020 5:12 pm
who navigates in insert mode? :roll:
:)

bls
Posts: 718
Joined: Mon Oct 22, 2018 11:25 pm
Location: Seattle, WA
Contact: Twitter

Re: Buster/Debian vi/vim cursor key misconfiguration and workaround

Thu May 21, 2020 6:45 pm

busywait wrote:
Thu May 21, 2020 6:31 pm
bls wrote:
Thu May 21, 2020 5:22 pm
Just tried this on an xterm connected to a Pi4, with Buster 2020-02-13 Lite and the same version of vim as you, and did not see the behavior you're reporting. Possibly a termcap issue? What are the contents of your /etc/default/keyboard?

Code: Select all

pi@raspi4:~ $ cat /etc/default/keyboard
# KEYBOARD CONFIGURATION FILE

# Consult the keyboard(5) manual page.

XKBMODEL="pc105"
XKBLAYOUT="gb"
XKBVARIANT=""
XKBOPTIONS=""

BACKSPACE="guess"

kerry_s wrote:
Thu May 21, 2020 5:12 pm
who navigates in insert mode? :roll:
:)
Still works correctly for me. Please post the output of

Code: Select all

echo $TERM
stty -a
Pi tools:
Easily and quickly build customized-just-for-you SD Cards: https://github.com/gitbls/sdm
Free your network from your router's DHCP/DNS:https://github.com/gitbls/ndm
Easy strongSwan VPN installer/manager: https://github.com/gitbls/pistrong
Lightweight Virtual VNC Config: https://github.com/gitbls/RPiVNCHowTo

busywait
Posts: 64
Joined: Sat May 09, 2020 10:48 pm
Location: Southampton, UK

Re: Buster/Debian vi/vim cursor key misconfiguration and workaround

Thu May 21, 2020 6:54 pm

bls wrote:
Thu May 21, 2020 6:45 pm
Still works correctly for me. Please post the output of

Code: Select all

echo $TERM
stty -a
I only see the problem when there is no .vimrc file in my home directory (there was not one by default in my clean Buster full install). Have you renamed yours if you have a .vimrc?

Here's the output through ssh...

Code: Select all

pi@raspi4:~ $ echo $TERM
xterm-256color

pi@raspi4:~ $ stty -a
speed 38400 baud; rows 30; columns 120; line = 0;
intr = ^C; quit = ^\; erase = ^?; kill = ^U; eof = ^D; eol = M-^?; eol2 = M-^?; swtch = <undef>; start = ^Q; stop = ^S;
susp = ^Z; rprnt = ^R; werase = ^W; lnext = ^V; discard = ^O; min = 1; time = 0;
-parenb -parodd -cmspar cs8 -hupcl -cstopb cread -clocal -crtscts
-ignbrk -brkint -ignpar -parmrk -inpck -istrip -inlcr -igncr icrnl ixon -ixoff -iuclc ixany imaxbel iutf8
opost -olcuc -ocrnl onlcr -onocr -onlret -ofill -ofdel nl0 cr0 tab0 bs0 vt0 ff0
isig icanon iexten echo echoe echok -echonl -noflsh -xcase -tostop -echoprt echoctl echoke -flusho -extproc

busywait
Posts: 64
Joined: Sat May 09, 2020 10:48 pm
Location: Southampton, UK

Re: Buster/Debian vi/vim cursor key misconfiguration and workaround

Thu May 21, 2020 7:08 pm

Interesting - if I log directly into the console, then there is no problem in vi even without .vimrc:

Code: Select all

 $ echo $TERM
linux

$ stty -a
speed 38400 baud; rows 67; columns 240; line = 0;
intr = ^C; quit = ^\; erase = ^?; kill = ^U; eof = ^D; eol = <undef>;
eol2 = <undef>; swtch = <undef>; start = ^Q; stop = ^S; susp = ^Z; rprnt = ^R;
werase = ^W; lnext = ^V; discard = ^O; min = 1; time = 0;
-parenb -parodd -cmspar cs8 hupcl -cstopb cread -clocal -crtscts
-ignbrk brkint -ignpar -parmrk -inpck -istrip -inlcr -igncr icrnl ixon -ixoff
-iuclc -ixany imaxbel iutf8
opost -olcuc -ocrnl onlcr -onocr -onlret -ofill -ofdel nl0 cr0 tab0 bs0 vt0 ff0
isig icanon iexten echo echoe echok -echonl -noflsh -xcase -tostop -echoprt
echoctl echoke -flusho -extproc
stty -a
If I start the Rasberry Pi Desktop and start the default terminal then there is a problem in vi.

Code: Select all

pi@raspi4:~ $ echo $TERM
xterm-256color
pi@raspi4:~ $ stty -a
speed 38400 baud; rows 24; columns 80; line = 0;
intr = ^C; quit = ^\; erase = ^?; kill = ^U; eof = ^D; eol = <undef>;
eol2 = <undef>; swtch = <undef>; start = ^Q; stop = ^S; susp = ^Z; rprnt = ^R;
werase = ^W; lnext = ^V; discard = ^O; min = 1; time = 0;
-parenb -parodd -cmspar cs8 -hupcl -cstopb cread -clocal -crtscts
-ignbrk -brkint -ignpar -parmrk -inpck -istrip -inlcr -igncr icrnl ixon -ixoff
-iuclc -ixany -imaxbel iutf8
opost -olcuc -ocrnl onlcr -onocr -onlret -ofill -ofdel nl0 cr0 tab0 bs0 vt0 ff0
isig icanon iexten echo echoe echok -echonl -noflsh -xcase -tostop -echoprt
echoctl echoke -flusho -extproc
And, the problem goes away everywhere if I create myself a .vimrc.

bls
Posts: 718
Joined: Mon Oct 22, 2018 11:25 pm
Location: Seattle, WA
Contact: Twitter

Re: Buster/Debian vi/vim cursor key misconfiguration and workaround

Thu May 21, 2020 7:15 pm

busywait wrote:
Thu May 21, 2020 6:54 pm

I only see the problem when there is no .vimrc file in my home directory (there was not one by default in my clean Buster full install). Have you renamed yours if you have a .vimrc?

Here's the output through ssh...

Code: Select all

pi@raspi4:~ $ echo $TERM
xterm-256color

pi@raspi4:~ $ stty -a
speed 38400 baud; rows 30; columns 120; line = 0;
intr = ^C; quit = ^\; erase = ^?; kill = ^U; eof = ^D; eol = M-^?; eol2 = M-^?; swtch = <undef>; start = ^Q; stop = ^S;
susp = ^Z; rprnt = ^R; werase = ^W; lnext = ^V; discard = ^O; min = 1; time = 0;
-parenb -parodd -cmspar cs8 -hupcl -cstopb cread -clocal -crtscts
-ignbrk -brkint -ignpar -parmrk -inpck -istrip -inlcr -igncr icrnl ixon -ixoff -iuclc ixany imaxbel iutf8
opost -olcuc -ocrnl onlcr -onocr -onlret -ofill -ofdel nl0 cr0 tab0 bs0 vt0 ff0
isig icanon iexten echo echoe echok -echonl -noflsh -xcase -tostop -echoprt echoctl echoke -flusho -extproc
What is the terminal device that you're using that you ssh from? I'm using a standard xterm, and my TERM shows up just like yours (xterm-256color).

The only differences between your stty -a output and mine are i have -ixany and -imaxbel, but those dont' seem to be relevant, based on the descriptions in 'man stty'.

Not sure what to explore or suggest next.

Oh, and back to your original question, the system-wide vimrc default is at /etc/vim/vimrc. It's also at /usr/share/vim/vimrc, which is a symlink to the one in /etc/vim/vimrc.
Pi tools:
Easily and quickly build customized-just-for-you SD Cards: https://github.com/gitbls/sdm
Free your network from your router's DHCP/DNS:https://github.com/gitbls/ndm
Easy strongSwan VPN installer/manager: https://github.com/gitbls/pistrong
Lightweight Virtual VNC Config: https://github.com/gitbls/RPiVNCHowTo

bls
Posts: 718
Joined: Mon Oct 22, 2018 11:25 pm
Location: Seattle, WA
Contact: Twitter

Re: Buster/Debian vi/vim cursor key misconfiguration and workaround

Thu May 21, 2020 7:15 pm

bls wrote:
Thu May 21, 2020 7:15 pm
busywait wrote:
Thu May 21, 2020 6:54 pm

I only see the problem when there is no .vimrc file in my home directory (there was not one by default in my clean Buster full install). Have you renamed yours if you have a .vimrc?

Here's the output through ssh...

Code: Select all

pi@raspi4:~ $ echo $TERM
xterm-256color

pi@raspi4:~ $ stty -a
speed 38400 baud; rows 30; columns 120; line = 0;
intr = ^C; quit = ^\; erase = ^?; kill = ^U; eof = ^D; eol = M-^?; eol2 = M-^?; swtch = <undef>; start = ^Q; stop = ^S;
susp = ^Z; rprnt = ^R; werase = ^W; lnext = ^V; discard = ^O; min = 1; time = 0;
-parenb -parodd -cmspar cs8 -hupcl -cstopb cread -clocal -crtscts
-ignbrk -brkint -ignpar -parmrk -inpck -istrip -inlcr -igncr icrnl ixon -ixoff -iuclc ixany imaxbel iutf8
opost -olcuc -ocrnl onlcr -onocr -onlret -ofill -ofdel nl0 cr0 tab0 bs0 vt0 ff0
isig icanon iexten echo echoe echok -echonl -noflsh -xcase -tostop -echoprt echoctl echoke -flusho -extproc
What is the terminal device that you're using that you ssh from? I'm using a standard xterm, and my TERM shows up just like yours (xterm-256color).

The only differences between your stty -a output and mine are i have -ixany and -imaxbel, but those dont' seem to be relevant, based on the descriptions in 'man stty'.

Yes, no .vimrc file in my home directory.

Not sure what to explore or suggest next.

Oh, and back to your original question, the system-wide vimrc default is at /etc/vim/vimrc. It's also at /usr/share/vim/vimrc, which is a symlink to the one in /etc/vim/vimrc.
Pi tools:
Easily and quickly build customized-just-for-you SD Cards: https://github.com/gitbls/sdm
Free your network from your router's DHCP/DNS:https://github.com/gitbls/ndm
Easy strongSwan VPN installer/manager: https://github.com/gitbls/pistrong
Lightweight Virtual VNC Config: https://github.com/gitbls/RPiVNCHowTo

busywait
Posts: 64
Joined: Sat May 09, 2020 10:48 pm
Location: Southampton, UK

Re: Buster/Debian vi/vim cursor key misconfiguration and workaround

Thu May 21, 2020 7:31 pm

bls wrote:
Thu May 21, 2020 7:15 pm
The only differences between your stty -a output and mine are i have -ixany and -imaxbel, but those dont' seem to be relevant, based on the descriptions in 'man stty'.

Yes, no .vimrc file in my home directory.

Not sure what to explore or suggest next.
Well, thanks for looking. Very strange it doesn't hit you, but perhaps there's some other locale related variation?

I can't believe it would just be me that sees this. It happens right in the default Raspberry Pi x-term, and also from the ssh command line client in Ubuntu for Windows, and PuTTY for Windows.

I've found that it is not a problem in the default TTY console.

My problem goes away everywhere when I copy /etc/vim/vimrc in to my own home directory as ".vimrc". So, it seemed to me like this was an oversight in the default install.

User avatar
kerry_s
Posts: 976
Joined: Thu Jan 30, 2020 7:14 pm

Re: Buster/Debian vi/vim cursor key misconfiguration and workaround

Thu May 21, 2020 7:36 pm

there is no problem, this is user error.
your not suppose to navigate in "insert" mode, you edit/change/replace whatever & press "esc" then move/navigate.

you should use "vimtutor" to learn the basics.

User avatar
PeterO
Posts: 5958
Joined: Sun Jul 22, 2012 4:14 pm

Re: Buster/Debian vi/vim cursor key misconfiguration and workaround

Thu May 21, 2020 7:37 pm

ISTR vi is installed by default. You have to install vim yourself.
PeterO
Discoverer of the PI2 XENON DEATH FLASH!
Interests: C,Python,PIC,Electronics,Ham Radio (G0DZB),1960s British Computers.
"The primary requirement (as we've always seen in your examples) is that the code is readable. " Dougie Lawson

busywait
Posts: 64
Joined: Sat May 09, 2020 10:48 pm
Location: Southampton, UK

Re: Buster/Debian vi/vim cursor key misconfiguration and workaround

Thu May 21, 2020 9:12 pm

PeterO wrote:
Thu May 21, 2020 7:37 pm
ISTR vi is installed by default. You have to install vim yourself.
PeterO
I type vi to run the editor, but it runs vim; if I ask apt, there is no vi package, but there is a vim package:

Code: Select all

pi@raspi4:~ $ vi --version
VIM - Vi IMproved 8.1 (2018 May 18, compiled Jun 15 2019 16:41:15)
Included patches: 1-875, 878, 884, 948, 1046, 1365-1368, 1382, 1401
Modified by team+vim@tracker.debian.org
Compiled by team+vim@tracker.debian.org
Small version without GUI.  Features included (+) or not (-):
...
pi@raspi4:~ $ apt info vi
N: Unable to locate package vi
N: Unable to locate package vi
E: No packages found
Last edited by busywait on Thu May 21, 2020 9:24 pm, edited 1 time in total.

User avatar
kerry_s
Posts: 976
Joined: Thu Jan 30, 2020 7:14 pm

Re: Buster/Debian vi/vim cursor key misconfiguration and workaround

Thu May 21, 2020 9:23 pm

most linux only use the "vim-tiny" as nano is the default, considered more user friendly.

Code: Select all

show vim-tiny
Package: vim-tiny
Version: 2:8.1.0875-5
Priority: important
Section: editors
Source: vim
Maintainer: Debian Vim Maintainers <team+vim@tracker.debian.org>
Installed-Size: 1,098 kB
Provides: editor
Depends: vim-common (= 2:8.1.0875-5), libacl1 (>= 2.2.23), libc6 (>= 2.28), libselinux1 (>= 1.32), libtinfo6 (>= 6)
Suggests: indent
Homepage: https://www.vim.org/
Download-Size: 503 kB
APT-Manual-Installed: yes
APT-Sources: http://raspbian.raspberrypi.org/raspbian buster/main armhf Packages
Description: Vi IMproved - enhanced vi editor - compact version
 Vim is an almost compatible version of the UNIX editor Vi.
 .
 This package contains a minimal version of Vim compiled with no GUI and
 a small subset of features. This package's sole purpose is to provide
 the vi binary for base installations.
 .
 If a vim binary is wanted, try one of the following more featureful
 packages: vim, vim-nox, vim-athena, vim-gtk, or vim-gtk3.


User avatar
DougieLawson
Posts: 39568
Joined: Sun Jun 16, 2013 11:19 pm
Location: A small cave in deepest darkest Basingstoke, UK
Contact: Website Twitter

Re: Buster/Debian vi/vim cursor key misconfiguration and workaround

Thu May 21, 2020 9:30 pm

First thing I do on any new Raspbian install is sudo apt install vim-full to make it work normally.
Note: Any requirement to use a crystal ball or mind reading will result in me ignoring your question.

Criticising any questions is banned on this forum.

Any DMs sent on Twitter will be answered next month.
All fake doctors are on my foes list.

User avatar
Paeryn
Posts: 3010
Joined: Wed Nov 23, 2011 1:10 am
Location: Sheffield, England

Re: Buster/Debian vi/vim cursor key misconfiguration and workaround

Thu May 21, 2020 9:35 pm

PeterO wrote:
Thu May 21, 2020 7:37 pm
ISTR vi is installed by default. You have to install vim yourself.
PeterO
The default is vim-tiny which is basically vim compiled to only work in vi-compatible mode and without all the useful things vim has. Also the full vim will default to vi-compatible mode if there isn't a .vimrc (or .vim/vimrc). I've never understood why distros use vim-tiny (apart from severely space restricted ones).
kerry_s wrote:
Thu May 21, 2020 7:36 pm
there is no problem, this is user error.
your not suppose to navigate in "insert" mode, you edit/change/replace whatever & press "esc" then move/navigate.

you should use "vimtutor" to learn the basics.
It's not user error, who says you aren't supposed to navigate in insert mode? The arrow keys, page up/down, home and end have always worked in insert mode (or have done for the last 25+ years I've been using vi & vim).

If you're getting the letters A, B, C or D when pressing a cursor key then it sounds like the escape-codes for the keys aren't being parsed correctly (up is Esc[A / EscOA etc.), we used to get that intermittently on terminals that had a very dodgy and slow connection to the workstations.
Last edited by Paeryn on Thu May 21, 2020 10:24 pm, edited 1 time in total.
She who travels light — forgot something.

busywait
Posts: 64
Joined: Sat May 09, 2020 10:48 pm
Location: Southampton, UK

Re: Buster/Debian vi/vim cursor key misconfiguration and workaround

Thu May 21, 2020 9:41 pm

kerry_s wrote:
Thu May 21, 2020 7:36 pm
there is no problem, this is user error.
your not suppose to navigate in "insert" mode, you edit/change/replace whatever & press "esc" then move/navigate.

you should use "vimtutor" to learn the basics.
Two different issues I think:
1/ I should run vimtutor to advance my vim skills - good idea, thanks!
2/ The default install of /usr/bin/vi should not dump unwanted characters into my text if I use the arrow keys while in insert mode

The silliness doesn't happen in Ubuntu 20.04, or in the the Gentoo for Raspbian that I've tried recently on my Pi, and it doesn't when I copy the /etc/vim/vimrc file to my home directory as .vimrc in Raspbian. (Or, perhaps these characters are a deliberate punishment to put me on to the true path to more enlightened vi editing?)

User avatar
kerry_s
Posts: 976
Joined: Thu Jan 30, 2020 7:14 pm

Re: Buster/Debian vi/vim cursor key misconfiguration and workaround

Thu May 21, 2020 10:16 pm

i think its a matter of how the distro chooses to compile/setup there version.

i've never navigated in "insert" in the many years i've used linux.
but then again i'm more use to moving around by # (example: 6j, 6w).

busywait
Posts: 64
Joined: Sat May 09, 2020 10:48 pm
Location: Southampton, UK

Re: Buster/Debian vi/vim cursor key misconfiguration and workaround

Thu May 21, 2020 11:03 pm

DougieLawson wrote:
Thu May 21, 2020 9:30 pm
First thing I do on any new Raspbian install is sudo apt install vim-full to make it work normally.
Ah, yep - sudo apt install vim does correct the arrow key behaviour too (the package is just vim, not vim-full) - also has vimtutor baked in to the help, thanks :)

User avatar
Paeryn
Posts: 3010
Joined: Wed Nov 23, 2011 1:10 am
Location: Sheffield, England

Re: Buster/Debian vi/vim cursor key misconfiguration and workaround

Thu May 21, 2020 11:08 pm

Looking through the docs, the original vi behaviour was to switch the terminal to Application mode (changes the key codes that the cursor and number pad keys send) and to not use the cursor application keys for movement when in edit mode.

Vim's behaviour is to allow the cursor keys to be used as movement keys even when in edit mode, but if vim-tiny is installed then you don't get vim's improvements like this.

So at a guess if, when using vim-tiny in a terminal, the cursor keys work as movement keys in edit mode then the terminal is probably set up to not switch the cursor keys to Application mode when asked to.

I probably used to have the cursor keys mapped in edit mode back before I discovered vim with things like this in my .virc file

Code: Select all

map! ^[OA ^[ka
She who travels light — forgot something.

bls
Posts: 718
Joined: Mon Oct 22, 2018 11:25 pm
Location: Seattle, WA
Contact: Twitter

Re: Buster/Debian vi/vim cursor key misconfiguration and workaround

Thu May 21, 2020 11:31 pm

Sigh...who would have thought it was a which-version-of-vim issue? Obviously not me! :oops:
Pi tools:
Easily and quickly build customized-just-for-you SD Cards: https://github.com/gitbls/sdm
Free your network from your router's DHCP/DNS:https://github.com/gitbls/ndm
Easy strongSwan VPN installer/manager: https://github.com/gitbls/pistrong
Lightweight Virtual VNC Config: https://github.com/gitbls/RPiVNCHowTo

User avatar
PeterO
Posts: 5958
Joined: Sun Jul 22, 2012 4:14 pm

Re: Buster/Debian vi/vim cursor key misconfiguration and workaround

Fri May 22, 2020 6:30 am

Paeryn wrote:
Thu May 21, 2020 9:35 pm
PeterO wrote:
Thu May 21, 2020 7:37 pm
ISTR vi is installed by default. You have to install vim yourself.
PeterO
The default is vim-tiny which is basically vim compiled to only work in vi-compatible mode and without all the useful things vim has. Also the full vim will default to vi-compatible mode if there isn't a .vimrc (or .vim/vimrc). I've never understood why distros use vim-tiny (apart from severely space restricted ones).
Thanks, I've never looked into it in that closely :-)
PeterO
Discoverer of the PI2 XENON DEATH FLASH!
Interests: C,Python,PIC,Electronics,Ham Radio (G0DZB),1960s British Computers.
"The primary requirement (as we've always seen in your examples) is that the code is readable. " Dougie Lawson

busywait
Posts: 64
Joined: Sat May 09, 2020 10:48 pm
Location: Southampton, UK

Re: Buster/Debian vi/vim cursor key misconfiguration and workaround

Fri May 22, 2020 8:47 pm

bls wrote:
Thu May 21, 2020 11:31 pm
Sigh...who would have thought it was a which-version-of-vim issue? Obviously not me! :oops:
:) Sorry, I misdirected you by showing an output from "apt info vim" in my first post. I've worked out how to query for the actually installed version of a binary now, and edited my post up above.

Code: Select all

pi@raspi3b:~ $ which vi
/usr/bin/vi
pi@raspi3b:~ $ ls -l /usr/bin/vi
lrwxrwxrwx 1 root root 20 Feb 13 15:54 /usr/bin/vi -> /etc/alternatives/vi
pi@raspi3b:~ $ ls -l /etc/alternatives/vi
lrwxrwxrwx 1 root root 17 Feb 13 15:54 /etc/alternatives/vi -> /usr/bin/vim.tiny
pi@raspi3b:~ $ ls -l /usr/bin/vim.tiny
-rwxr-xr-x 1 root root 921704 Jun 15  2019 /usr/bin/vim.tiny
pi@raspi3b:~ $ dpkg -S /usr/bin/vim.tiny
vim-tiny: /usr/bin/vim.tiny
or

Code: Select all

pi@raspi3b:~ $ dpkg -S $(realpath $(which vi))
vim-tiny: /usr/bin/vim.tiny
So, *vim-tiny*, the default package that provides vi in the Raspbian full install images, doesn't allow using cursor key navigation in insert mode, perhaps because it is missing a default.vim file. And I have two easy ways to make the problem go away.

swaps
Posts: 2
Joined: Mon Jun 15, 2020 6:34 am

Re: Buster/Debian vi/vim cursor key misconfiguration and workaround

Mon Jun 15, 2020 6:40 am

It looks like

Code: Select all

:set term=builtin_ansi  
fixed the issue for me .
To make it permanent hope this helps

Code: Select all


$ cat   <<EOF>  ~/.vimrc
set term=builtin_ansi
set mouse=r
EOF


swaps
Posts: 2
Joined: Mon Jun 15, 2020 6:34 am

Re: Buster/Debian vi/vim cursor key misconfiguration and workaround

Mon Jun 15, 2020 6:48 am

this seems to help

Code: Select all

:set term=builtin_ansi
to make it permanent

Code: Select all

cat   <<EOF>  ~/.vimrc
set term=builtin_ansi
set mouse=r
EOF

Return to “Raspberry Pi OS”