Eugeny / tabby

A terminal for a more modern age
https://tabby.sh
MIT License
58.26k stars 3.35k forks source link

alt+left and alt+right shortcut keys fail when using vim or vi #8900

Open zhangshiboaa opened 1 year ago

zhangshiboaa commented 1 year ago

Describe the problem: i use alt+left and right to switch tab, but it's not work when i edit the file with vim. The function of the shortcut keys is replaced by word jumping

orazmyradov commented 1 year ago

The issue you're experiencing where the Alt+Left and Alt+Right keyboard shortcuts are not working as expected in Vim is likely due to Vim's keybindings conflicting with your terminal emulator or desktop environment's shortcuts. Vim has its own keybindings that might interfere with the system-wide shortcuts.

To resolve this issue, you can consider the following steps:

  1. Check Vim Configuration:

    • Review your Vim configuration files, such as .vimrc or .vimrc.local, to see if you have any custom key mappings that might override the Alt+Left and Alt+Right shortcuts. Look for lines like map or noremap that could be causing the conflict.
  2. Check Terminal Emulator Shortcuts:

    • Some terminal emulators have their own keyboard shortcuts that can interfere with Vim. Check your terminal emulator settings to see if there are any shortcuts assigned to Alt+Left and Alt+Right. If possible, disable or modify these shortcuts to avoid conflicts.
  3. Vim Key Mapping:

    • You can remap Vim's keybindings to use different key combinations if needed. For example, you can add the following lines to your .vimrc to map Alt+Left and Alt+Right to switch between tabs:

      " Map Alt+Left to switch to previous tab
      nnoremap <M-Left> :tabprevious<CR>
      inoremap <M-Left> <Esc>:tabprevious<CR>
      
      " Map Alt+Right to switch to next tab
      nnoremap <M-Right> :tabnext<CR>
      inoremap <M-Right> <Esc>:tabnext<CR>

    These mappings will allow you to use Alt+Left and Alt+Right to switch between Vim tabs.

  4. Terminal Emulator Configuration:

    • If the issue persists, check your terminal emulator's settings for keybindings and shortcuts. Some terminal emulators allow you to configure how certain key combinations are handled, and you may need to adjust these settings to prevent conflicts.
  5. Desktop Environment Shortcuts:

    • In some cases, your desktop environment might also have global shortcuts that use Alt+Left or Alt+Right. Check your desktop environment's keyboard shortcut settings and modify or disable any conflicting shortcuts.
  6. Test in Different Terminal Emulators:

    • If you're still experiencing issues, try running Vim in a different terminal emulator to see if the problem persists. Some terminal emulators handle keybindings differently, and you may find that the shortcuts work as expected in a different emulator.
zhangshiboaa commented 1 year ago

1: I checked the vim configuration of the server and there is nothing map related. The same problem will occur in vi, I'm not sure about the other editors 2&4: my Terminal Emulator is tabby, so that i commit issue here. and i'm sure that there is no shortcuts conflicts in tabby's shortcuts settings 3: I have a large number of servers to access, and they are public, so I can't add vim configurations at will. 5: I am using Windows 11, I think there is no alt+left conflict configuration, and it is used when tabby is in focus, should not be obtained by other app shortcut keys 6: Previously, I used Xshell and configured the same shortcut keys and did not encounter this problem

Xerxes-zhz commented 4 months ago

I met the same problem today. Alt key won't work in vim with Alt/Meta setting off which in Setting-Terminal-Keyboard. But after set the setting on, there still another problem that quick tap will perform as Meta, same as Alt, which slow down efficiency of vim workflow.