Skip to content

Instantly share code, notes, and snippets.

@csghone
Last active May 14, 2025 02:59
Show Gist options
  • Save csghone/54602839fb0431b30799d958f7de0519 to your computer and use it in GitHub Desktop.
Save csghone/54602839fb0431b30799d958f7de0519 to your computer and use it in GitHub Desktop.
VSCode + VIM + NVIM + WSL

Setup WSL 2

Setup Neovim

sudo add-apt-repository ppa:neovim-ppa/unstable
sudo apt-get update
sudo apt-get install neovim
sudo apt install python-neovim
sudo apt install python3-neovim # Alternatively `pip install neovim` in your venv
  • Setup init.vim (vimrc equivalent)
mkdir -p ~/.config/nvim
ln -s ~/.vimrc ~/.config/nvim/init.vim
  • Edit .vimrc to use if has('nvim') as needed to add/remove settings between vim/neovim

Setup VIM

VSCode + VIM/NVIM

Option 1 (VIM)

	"vim.enableNeovim": true,
	"remote.extensionKind": {
		"vscodevim.vim": [
			"workspace"
		]
	}
  • Can be used with normal vim as well. (Set vim.enableNeovim to false)

Option 2 (NEOVIM)

  • Needed to allow using linux shell commands with ! even when editing files in Windows
  • Allows using neovim extensions
  • Install Neo Vim extension
  • Update global settings.json
	"vscode-neovim.useWSL": true,
	"vscode-neovim.neovimExecutablePaths.linux": "/usr/bin/nvim",
	"remote.extensionKind": {
		"asvetliakov.vscode-neovim": [
			"workspace"
		]
	}

Misc VSCode settings

	"editor.minimap.enabled": false,
	"editor.fontFamily": "mononoki, Consolas, 'Courier New', monospace",
	"editor.fontSize": 13,
	"editor.tabSize": 4,
	"editor.insertSpaces": true,
	"editor.rulers": [
		80
	],
	"editor.selectionHighlight": false,
	"files.eol": "\n",
	"files.trimTrailingWhitespace": true,
		"terminal.integrated.commandsToSkipShell": [
		"-workbench.action.terminal.paste"
	]

Vim yanks to clipboard

  • Install X Server: VcXsrv
  • Set environment variable 'DISPLAY = 127.0.0.1:0'
  • Changes to vimrc/init.vim
set clipboard^=unnamed     " Yanks go on clipboard
set clipboard^=unnamedplus " Yanks go on clipboard
  • Changes to .ssh/config
Host host_alias
    HostName host_ip_or_host_fqdn
    User username
    ForwardX11 yes
    ForwardX11Trusted yes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment