5

I am failing to map Command+T, Command+[ and Command+] keys in Neovim under macOS / Alacritty.

I've reduced my Alacritty to be minimal:

env:
  TERM: xterm-256color
font:
  size: 16
key_bindings:
  - {key: T,        mods: Command, chars: "\×80\xfc\x80t"}
  - {key: LBracket, mods: Command, chars: "\×80\xfc\×80["}
  - {key: Bracket,  mods: Command, chars: "\×80\xfc\×80]"}

And also Neovim's:

vim.kevmap.set('n', '<D-t>', vim.cmd.tabnew)
vim.keymap.set('n', '<D-[>', vim.cmd.tabprevious)
vim.keymap.set('n', '<D-]>', vim.cmd.tabnext)
  1. I went to nvim,

  2. entered the following command,

    echo "\<D-t>"
    
  3. got an output:

    <80><fc><80>t
    
  4. used the output to add a binding in Alacritty:

    - { key: T, mods: Command, chars: "\x80\xfc\x80t" }
    

What am I doing wrong?

2
  • 1
    Please don’t post images of text. Just post code blocks of your config files.
    – D. Ben Knoble
    Commented Apr 23, 2023 at 17:40
  • Does mapping ×80\xfc\x80t work? You can try using <C-v><C-t> to insert that direct sequence, but you can probably also use some escape sequence (I'm not that familiar with Neovim's lua stuff). Commented Jun 23, 2023 at 17:11

1 Answer 1

1

What I ended up doing was going to Neovim opening a new file and going into insert mode.

Then typing the key combo I was hoping to bind.

In this case Command + Shift + {. When I did this I was able to see what key Alacritty was sending to Neovim.

<S-D-{>

Then I was able to use this keybinding in my config.

vim.keymap.set("n", "<S-D-{>", "<cmd>bp<CR>", { silent = true })
vim.keymap.set("n", "<S-D-}>", "<cmd>bn<CR>", { silent = true })

I hope that helps!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.