2

Vim + Catalina

I just switched to MacOS Catalina which has zsh and vim 8.1 out-of-the-box.

VIM - Vi IMproved 8.1 (2018 May 18, compiled Dec 13 2019 14:45:40)
Included patches: 1-503, 505-680, 682-1312
Compiled by [email protected]

I use Karabiner Elements and BetterTouchTool to map Caps Lock to delete_or_backspace and Delete to delete_forward (aka fn+delete).

Delete Forward => Case Swap

I'm having an issue where the use of delete_forward (fn+delete) replaces whatever is under the cursor with the opposite case.

For example, suppose I have this text:

func SomeFunc() {
  return true
}

Whether I stay in command(?) mode or I'm in insert mode, using forward delete will swap the case, like this:

FUNC sOMEfUNC() {
  RETURN TRUE
}

What my delete_forward looks like:

It seems to be functioning as expected in all other programs. This is the escape sequence that I get for it:

cat 
hello^[[3~^[[3~^[[3~^[[3~^[[3~

That's me typing 5 letters ('hello') and then hitting forward delete 5 times.

Also, here's what I get from :set t_kD inside of vim:

E846: Key code not set: t_kD

:echo $TERM reveals the following:

ansi

:set term? gives:

  term=ansi

What to do?

I've seen this happen in the past, but I never knew what caused it and if I just mashed escape or quit and started again it would fix itself. On my new computer... it's there to stay.

I imagine this is just some sort of new default or option that I've enabled by accident.

None of my plugins (sensible, syntastic, solarized, rust) seem to be loading anyway, but I doubt that they'd be at fault for this.

10
  • If you're on the terminal, type cat, enter (to run the cat command) and while entering characters for it, enter a fn+delete, what do you see? I'm guessing something starting with ^[[ and having a ~ in it somewhere? But knowing exactly what should help figure out your particular case...
    – filbranden
    Commented Feb 24, 2020 at 17:15
  • 1
    @filbranden I see ~^[[3 (question edited above).
    – coolaj86
    Commented Feb 24, 2020 at 20:15
  • Inside Vim, what does :set t_kD return? Wat about :echo $TERM?
    – filbranden
    Commented Feb 24, 2020 at 22:32
  • @filbranden I get some errors E846: Key code not set: t_kD and E15: Invalid expression: $TERM
    – coolaj86
    Commented Feb 25, 2020 at 5:22
  • Odd, I can't reproduce E15 even if the $TERM variable is empty... In your shell, is $TERM set? How about :set term? inside Vim? (Your problem is probably related to the terminal setting!)
    – filbranden
    Commented Feb 25, 2020 at 5:25

1 Answer 1

1

The problem you were having was related to the terminal setting, which you can find in the $TERM environment variable or in the :set term? option in Vim.

You had that variable set to ansi, which is a terminal setting fairly poor in features, missing a lot of the colors and support for special keys such as arrow keys, delete, etc.

You should configure your terminal setting to use a more featureful terminal, such as xterm or ideally xterm-256color.

In chat, we established you most likely got this setting from a profile in Terminal.app for the Solarized color scheme. Since the profiles include settings for everything (not just the color scheme), this ansi terminal emulation setting came with it. Switch it to xterm-256color and start a new shell (to get $TERM set right) and you should be good to go!

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .