Keyboard controlled VS Code with Vim and Tmux
Near the end of 2023 I abandoned Neovim because I missed many features of modern editors. The Neovim setup I used was basically a keyboard‑first VS Code without a debugger and with around 30 plugins. In my years of using Neovim I learned a lot about how to get more out of it, so I don't see it as a waste (there is always more to learn).
When I was using VS Code with the Vim plugin a few years back, my setup was nowhere near as good as it is now, so I am happy to share some ideas from my most recent config for anyone looking for tips and tricks to improve their development workflow.
Tools I am using
- Fish shell:
zshis also great, Fish excels in autocomplete for Node devs (e.g., npm/yarn suggestions), but zsh plugins like Oh My Zsh cover 95% of those needs with broader ecosystem support. - Tmux: Mainly for Vi key mode, so I can select and copy text—in VS Code or iTerm, I just use
q+Spaceto start copy mode and select text withhjkl. - VSCodeVim plugin: there are other plugins but this one was relatively easy to configure to emulate my Neovim setup
- VS Code keybindings and settings: lots of fine tuning to make everything work, will try to keep it updated in my dotfiles
tmux.conf
set -g status-keys vi
set-window-option -g mode-keys vi
bind-key Space copy-mode
settings.json
"terminal.integrated.profiles.osx": {
"tmux-shell": {
"path": "tmux",
"args": [
"new-session",
"-A",
"-s",
"vscode:${workspaceFolder}"
]
}
}
keybindings.json - hjkl navigation inside VS Code
{
"key": "ctrl+h",
"command": "workbench.action.navigateLeft",
},
{
"key": "ctrl+j",
"command": "workbench.action.navigateDown",
},
{
"key": "ctrl+k",
"command": "workbench.action.navigateUp",
},
{
"key": "ctrl+l",
"command": "workbench.action.navigateRight",
}
VSCodeVim configuration
I use many Vim keybindings, which you can find in my configuration files.
settings.json
"vim.replaceWithRegister": true,
"vim.camelCaseMotion.enable": true,
"vim.highlightedyank.enable": true,
"vim.hlsearch": true,
"vim.easymotion": true,
"vim.leader": " ",
"vim.useSystemClipboard": true,
"vim.visualstar": true
Vim: Replace with Register
Allows me to use substitute operation in a very useful way, so that I can just do siw to overwrite word with the contents of my clipboard. I got used to this behavior from vim-subversive.
Vim: Surround
This plugin is enabled by default and makes it super easy to surround text in any symbol pair. I use this in both normal and visual mode to surround any block of text with brackets, quotes etc.
Vim: Camel Case Motion
Easy navigation by part of words using w, b, e etc. in camelCase text.
Vim: Easymotion
Similar to many jump plugins, probably not the best but good enough. The plugin allows to jump to any symbol or word on the screen.
I personally map it to s (forwards) and S (backwards) in normal mode followed by the start of a letter.
Outside of VS Code
I use keyboard hotkeys to switch between Chrome and VS Code with one shortcut. I find this even better than using multiple monitors and moving my eyes, also less straining on my neck if the monitor distance is suboptimal, more scalable and portable.