Leland Kilborn
Leland Kilborn

Reputation: 31

How can I change the cursor keys in the VIM extension for vscode

I use the Colemak DH mod layout, which moves around the default keys used for navigation in normal mode. I was wondering if there was any way to remap the hjkl cursor key combo to mnei, or better yet, neio. I am not actually using vim, but rather using the VIM extension for vscode. I've been looking around the internet, but I couldn't find anything.

Upvotes: 3

Views: 2463

Answers (1)

Stvad
Stvad

Reputation: 380

I know of two ways of doing so:

Approach 1 importing .vimrc

That's what I'm currently using. I have the following settings in the VSCode config, that make VIM plugin to load the specified vimrc file

    "vim.vimrc.enable": true,
    "vim.vimrc.path": "$HOME/.vim/vimrc_vscode",

And then in vimrc_vscode:

nnoremap j h
nnoremap k j
nnoremap h k


vnoremap j h
vnoremap k j
vnoremap h k

Approach 2 VS code settings

You can use the "non recursive" remapping setting to swap the keys the way you want.

Example (swap j and k):

    "vim.normalModeKeyBindingsNonRecursive": [
        {
            "before": ["j"],
            "after": ["k"]
        },
        {
            "before": ["k"],
            "after": ["j"]
        }
    ]

See more at https://github.com/VSCodeVim/Vim#viminsertmodekeybindingsnonrecursivenormalmodekeybindingsnonrecursivevisualmodekeybindingsnonrecursiveoperatorpendingmodekeybindingsnonrecursive

Upvotes: 4

Related Questions