DEV Community

Discussion on: Bring Your Vim/Tmux Navigation Reflexes to VS Code

Collapse
 
lxmrc profile image
Alex

Hi AJ, thanks for writing this. I'm looking at switching from vim/tmux to VS Code too. If you could show me how to bind leader + | and leader + - to create vertical and horizontal splits that would be awesome.

Collapse
 
ajkerrigan profile image
AJ Kerrigan • Edited

Hi Alex, that seems like a handy binding :). At first I thought the easiest way to handle that would be inside ~/.vimrc, coupled with the "Use key mappings from .vimrc" setting. That worked for split but not vsplit in my setup. That could be an issue just on my end, I've messed with my settings a bunch since this post!

That said, handling it from the VS Code side worked fine for me. The VSCodeVim extension lets you define mode-level overrides, so a block like this in your settings.json should do the trick:

"vim.normalModeKeyBindings": [
    {
        "before": ["<leader>", "|"],
        "commands": [
            "workbench.action.splitEditorRight"
        ]
    },
    {
        "before": ["<leader>", "-"],
        "commands": [
            "workbench.action.splitEditorDown"
        ]
    }
]
Enter fullscreen mode Exit fullscreen mode