2

I am trying to configure the key mappings for the barbar plugin commands, specifically the BufferMovePrevious and BufferMoveNext actions. The desired key combinations are Alt < and Alt >. However, despite my attempts, these mappings do not seem to be functioning properly. Also I am on Arch linux. Let me provide you with the different variations I have tried:

Initially, I attempted the following mappings:

map('n', '<A-<>', '<Cmd>BufferMovePrevious<CR>', opts)
map('n', '<A->>', '<Cmd>BufferMoveNext<CR>', opts)

I also experimented with the following mappings:

map('n', '<M-<>', '<Cmd>BufferMovePrevious<CR>', opts)
map('n', '<M->>', '<Cmd>BufferMoveNext<CR>', opts)

Additionally, I came across a suggestion in response to a similar question, and tried the following mappings:

map('n', '<¯>', '<Cmd>BufferMovePrevious<CR>', opts)
map('n', '<˘>', '<Cmd>BufferMoveNext<CR>', opts)

and nothing works, the content of :map is:
:map

Unfortunately, none of these attempts yielded the desired results. Upon inspecting the output of the :map command, I noticed that all my mappings, except for the ones related to the BufferMovePrevious and BufferMoveNext commands, are functioning correctly. Moreover, I observed that instead of the expected <M-<> notation, the mapping for these commands displays <M-lt>.

Considering the aforementioned details, I would greatly appreciate any guidance or alternative solutions you can provide to help me resolve this issue. Thank you in advance for your assistance.

1
  • 1
    Sometimes if you're using Vim under a terminal you can't map certain shifted-keys, such as the ones you want to map. Yes, <m-lt> is correct notation and Vim is understanding which key you want to map, but it's probably just not seeing the key combination due to the terminal emulator you're using.
    – Heptite
    May 29, 2023 at 18:16

2 Answers 2

1

Try using <M-S-,> and <M-S-.>:

nnoremap <silent>    <M-S-,> <Cmd>BufferMovePrevious<CR>
nnoremap <silent>    <M-S-.> <Cmd>BufferMoveNext<CR>

Background

I had this problem on MacOS/Kitty/Neovim. I investigated what keys Neovim saw with the following (method source):

  1. Switched to insert mode.
  2. Pressed ctrl+v
  3. Pressed alt+shift+,

That's how I saw <M-S-,>.

0

Are you using Mac? I have had a similar problem, and it apparently is due to how the keyboard send ≤ and ≥ instead of M-< and M->. Here is my barbar mapping which works correctly with those keys:

-- Move to previous/next (Alt+< or >)
vim.keymap.set('n', '≤', '<Cmd>BufferPrevious<CR>', opts)
vim.keymap.set('n', '≥', '<Cmd>BufferNext<CR>', opts)
-- Re-order to previous/next (Alt+Shift+< or >)
vim.keymap.set('n', '¯', '<Cmd>BufferMovePrevious<CR>', opts)
vim.keymap.set('n', '˘', '<Cmd>BufferMoveNext<CR>', opts)
-- Goto buffer in position (Alt + 0-9)
vim.keymap.set('n', '¡', '<Cmd>BufferGoto 1<CR>', opts)
vim.keymap.set('n', '™', '<Cmd>BufferGoto 2<CR>', opts)
vim.keymap.set('n', '£', '<Cmd>BufferGoto 3<CR>', opts)
vim.keymap.set('n', '¢', '<Cmd>BufferGoto 4<CR>', opts)
vim.keymap.set('n', '∞', '<Cmd>BufferGoto 5<CR>', opts)
vim.keymap.set('n', '§', '<Cmd>BufferGoto 6<CR>', opts)
vim.keymap.set('n', '¶', '<Cmd>BufferGoto 7<CR>', opts)
vim.keymap.set('n', '•', '<Cmd>BufferGoto 8<CR>', opts)
vim.keymap.set('n', 'ª', '<Cmd>BufferGoto 9<CR>', opts)
vim.keymap.set('n', 'º', '<Cmd>BufferLast<CR>', opts)
-- Pin/unpin buffer (Alt-P)
vim.keymap.set('n', 'π', '<Cmd>BufferPin<CR>', opts)
-- Close buffer (Alt-C)
vim.keymap.set('n', 'ç', '<Cmd>BufferClose<CR>', opts)
-- Close all but current (Alt-Shift-C)
vim.keymap.set('n', 'Ç', '<Cmd>BufferCloseAllButCurrent<CR>', opts)
-- Magic buffer-picking mode
vim.keymap.set('n', '<C-p>', '<Cmd>BufferPick<CR>', opts)
-- Sort automatically by...
vim.keymap.set('n', '<leader>bb', '<Cmd>BufferOrderByBufferNumber<CR>', opts)
vim.keymap.set('n', '<leader>bd', '<Cmd>BufferOrderByDirectory<CR>', opts)
vim.keymap.set('n', '<leader>bl', '<Cmd>BufferOrderByLanguage<CR>', opts)
vim.keymap.set('n', '<leader>bw', '<Cmd>BufferOrderByWindowNumber<CR>', opts)
2
  • no, I am not using mac and this does not work for me, thanks for the effort tho
    – Jastcher
    Jun 1, 2023 at 18:32
  • I see, sorry it doesn't help. Maybe try to use the keys in a text box or an input echo command and see if your OS/keyboard sends a different combo
    – casraf
    Jun 1, 2023 at 19:08

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.