修改Vim快捷键:Bepo键盘下替换hjkl为ctsr的方法
Hey there! Since you’re using a Bépo keyboard layout and want to swap the classic hjkl cursor movement keys with ctsr, the exact setup depends on which editor you’re using. Let’s break down the most common cases to get you sorted:
Vim/Neovim Configuration
Vim is the most common tool where hjkl is deeply ingrained, so this is probably what you’re asking about. Here’s how to set it up:
- Open your Vim configuration file:
~/.vimrcfor Vim, or~/.config/nvim/init.vimfor Neovim. - Add these lines to remap the cursor movement keys:
The" Map ctsr to left/down/up/right in normal mode nnoremap c h nnoremap t j nnoremap s k nnoremap r l " Optional: Insert mode movement (use Ctrl combinations to avoid input conflicts) inoremap <C-c> <Left> inoremap <C-t> <Down> inoremap <C-s> <Up> inoremap <C-r> <Right>nnoremapcommand creates non-recursive mappings, which means you won’t run into unexpected conflicts with existing shortcuts. For insert mode, using Ctrl+key combinations ensures you don’t overwrite the ability to type regular c/t/s/r characters.
VS Code Configuration
If you’re using VS Code (with or without the Vim extension), here’s how to adjust your keybindings:
- Open the settings panel with
Ctrl+,(Windows/Linux) orCmd+,(Mac). - Search for "Keyboard Shortcuts" and click "Open Keyboard Shortcuts (JSON)".
- Paste this configuration into the
keybindings.jsonfile:
If you don’t use the Vim extension, just replace the[ // Normal mode (for VS Code Vim extension users) { "key": "c", "command": "vim.left", "when": "editorTextFocus && vim.mode == 'Normal'" }, { "key": "t", "command": "vim.down", "when": "editorTextFocus && vim.mode == 'Normal'" }, { "key": "s", "command": "vim.up", "when": "editorTextFocus && vim.mode == 'Normal'" }, { "key": "r", "command": "vim.right", "when": "editorTextFocus && vim.mode == 'Normal'" }, // Optional: Insert mode movement { "key": "ctrl+c", "command": "cursorLeft", "when": "editorTextFocus && vim.mode == 'Insert'" }, { "key": "ctrl+t", "command": "cursorDown", "when": "editorTextFocus && vim.mode == 'Insert'" }, { "key": "ctrl+s", "command": "cursorUp", "when": "editorTextFocus && vim.mode == 'Insert'" }, { "key": "ctrl+r", "command": "cursorRight", "when": "editorTextFocus && vim.mode == 'Insert'" }, // Optional: Unbind original hjkl keys to prevent conflicts { "key": "h", "command": "-vim.left", "when": "editorTextFocus && vim.mode == 'Normal'" }, { "key": "j", "command": "-vim.down", "when": "editorTextFocus && vim.mode == 'Normal'" }, { "key": "k", "command": "-vim.up", "when": "editorTextFocus && vim.mode == 'Normal'" }, { "key": "l", "command": "-vim.right", "when": "editorTextFocus && vim.mode == 'Normal'" } ]vim.left/vim.downcommands withcursorLeft/cursorDownand adjust thewhencondition toeditorTextFocus && !editorReadonly.
General Tips for Other Editors
For tools like Sublime Text, Emacs, or any other editor with customizable shortcuts, the core idea is the same:
- Open the editor’s keyboard shortcut settings menu.
- Locate the "cursor left", "cursor down", "cursor up", "cursor right" commands.
- Bind each command to the corresponding c/t/s/r key (or use Ctrl combinations if you need to preserve the original key’s function for typing).
内容的提问来源于stack exchange,提问作者user8141907
相关产品推荐
相关产品推荐

