DISCLAIMER:
These are my notes for quick reference and not meant to be an exhaustive VSCode + NeoVim cheatsheet. Refer to VSCode, NeoVim and vscode-neovim documentation for the latest details.
- Install NeoVim 0.10.0+ and VSCode.
- Install vscode-neovim plugin in VSCode.
- Add the following to NeoVim's
init.lua
--- Bootstrap lazy.nvim local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim" if not (vim.uv or vim.loop).fs_stat(lazypath) then local lazyrepo = "https://github.com/folke/lazy.nvim.git" local out = vim.fn.system({ "git", "clone", "--filter=blob:none", "--branch=stable", lazyrepo, lazypath }) if vim.v.shell_error ~= 0 then vim.api.nvim_echo({ { "Failed to clone lazy.nvim:\n", "ErrorMsg" }, { out, "WarningMsg" }, { "\nPress any key to exit..." }, }, true, {}) vim.fn.getchar() os.exit(1) end end vim.opt.rtp:prepend(lazypath) -- Setup leader keys vim.g.mapleader = " " vim.g.maplocalleader = "\\" -- Set clipboard to global clipboard vim.opt.clipboard:append("unnamedplus") -- Setup lazy.nvim require("lazy").setup({ spec = { { "folke/flash.nvim", event = "VeryLazy", ---@type Flash.Config opts = { continue = true, modes = { search = { enabled = true }, char = { jump_labels = true }, } }, -- stylua: ignore keys = { { "s", mode = { "n", "x", "o" }, function() require("flash").jump() end, desc = "Flash" }, { "S", mode = { "n", "x", "o" }, function() require("flash").treesitter() end, desc = "Flash Treesitter" }, { "R", mode = { "o", "x" }, function() require("flash").treesitter_search() end, desc = "Treesitter Search" }, }, }, {"nvim-treesitter/nvim-treesitter", build = ":TSUpdate"}, }, -- Configure any other settings here. See the documentation for more details. -- Colorscheme that will be used when installing plugins. install = { colorscheme = { "habamax" } }, }) -- Highlight on yank vim.api.nvim_create_autocmd("TextYankPost", { desc = "Highlight yanked text", group = vim.api.nvim_create_augroup("neovim.highlight-yank", { clear = true }), callback = function() vim.highlight.on_yank() end, }) -- Key Bindings vim.keymap.set({ "n", "x" }, "<leader>a", 'ggVG"+y') vim.keymap.set({ "n", "x" }, "<leader>c", '"+y') vim.keymap.set({ "n", "x" }, "<leader>v", '"+p') vim.keymap.set({ "n", "x" }, "<leader>V", '"+P')
- Launch NeoVim to complete plugin setup with
lazy.nvim
. While you are there, install some tree-sitter parsers with:TSInstall <language>
. - (Optional) Add the following to VSCode's
settings.json
-"extensions.experimental.affinity": { "asvetliakov.vscode-neovim": 1 }, "vscode-neovim.compositeKeys": { "jj": { "command": "vscode-neovim.escape", }, "jk": { "command": "vscode-neovim.lua", "args": [ [ "local code = require('vscode')", "code.action('vscode-neovim.escape')", "code.action('workbench.action.files.save')", ], ], }, }, "vscode-neovim.highlightGroups.highlights": { "IncSearch": { "borderStyle": "solid", "borderWidth": "1px", "backgroundColor": "theme.editor.findMatchBackground" }, "CurSearch": { "borderStyle": "solid", "borderWidth": "1px", "backgroundColor": "theme.editor.findMatchBackground" }, "Search": { "borderStyle": "solid", "borderWidth": "1px", "backgroundColor": "theme.editor.findMatchHighlightBackground" }, "Substitute": { "borderStyle": "solid", "borderWidth": "1px", "backgroundColor": "theme.editor.foreground", "color": "theme.editor.background" } },
Keys | Action |
---|---|
F1 |
Open Command Palette |
Ctrl + Shift + p |
Open Command Palette |
Ctrl + Shift + n |
New VSCode Instance |
Ctrl + Shift + w |
Close VSCode Instance |
Ctrl + , |
Open User Settings |
Ctrl + Shift + e |
Open Explorer |
Ctrl + Shift + f |
Open Search |
Ctrl + Shift + j |
Togger Search Details |
Ctrl + Shift + g |
Open Source Control |
Ctrl + Shift + d |
Open Debug |
Ctrl + Shift + x |
Open Extensions |
Ctrl + Shift + u |
Toggle Output |
Ctrl + Shift + m |
Toggle Problems |
Ctrl + Shift + y |
Toggle Debug Console |
Ctrl + ` |
Toggle Terminal |
Ctrl + b |
Toggle Primary Side Bar Visibility (Has to be in focus!) |
Ctrl + j |
Toggle Panel Visibility (Has to be in focus!) |
Ctrl + o |
Open File or Folder (Depends on the context!) |
Ctrl + k f |
Close Folder |
↑ , ↓ , ← , → |
Move between Selections |
k , j , h , l |
Move between Selections |
Ctrl + n , Ctrl + p |
Move to Next or Previous Selection |
Keys | Action |
---|---|
a |
New File |
r |
Rename File |
v |
Open to Side |
d |
Delete File |
y |
Copy File |
x |
Cut File |
p |
Paste File |
A |
New Folder |
R |
Refresh File Explorer |
Keys | Action |
---|---|
:w<Enter> |
Save Editor |
:wa<Enter> |
Save All Editors with Changes |
:q<Enter> |
Close Editor |
:q!<Enter> |
Close Editor & Discard Changes |
:wq<Enter> |
Save and Close Editor |
:xa<Enter> |
Save and Close All Editors |
ZQ |
Close Editor & Discard Changes |
ZZ |
Save and Close Editor |
Ctrl + p |
Quick Open |
Ctrl + w n |
New Editor |
Ctrl + w q |
Close Editor |
Ctrl + w s |
Split Editor Horizontally |
Ctrl + w v |
Split Editor Vertically |
Ctrl + w = |
Make Editor Widths & Heights Even |
Ctrl + w + |
Increase Editor Height |
Ctrl + w - |
Decrease Editor Height |
Ctrl + w > |
Increase Editor Width |
Ctrl + w < |
Decrease Editor Width |
Ctrl + w Ctrl + ↑ |
Move Editor to Group Above |
Ctrl + w Ctrl + ↓ |
Move Editor to Group Below |
Ctrl + w Ctrl + ← |
Move Editor to Group on the Left |
Ctrl + w Ctrl + → |
Move Editor to Group on the Right |
Ctrl + w Shift + ↑ |
Move Active Editor Group Above |
Ctrl + w Shift + ↓ |
Move Active Editor Group Below |
Ctrl + w Shift + ← |
Move Active Editor Group on the Left |
Ctrl + w Shift + → |
Move Active Editor Group on the Right |
Ctrl + w o |
Join All Editor Groups |
Ctrl + w ↑ |
Jump to Editor Above |
Ctrl + w ↓ |
Jump to Editor Below |
Ctrl + w ← |
Jump to Editor on the Left |
Ctrl + w → |
Jump to Editor on the Right |
Ctrl + w p |
Jump to Previous Active Editor |
gT |
Jump to Previous Editor in Group |
gt |
Jump to Next Editor in Group |
+
is a special Register in NeoVim that maps to System Clipboard.
Keys | Action |
---|---|
"+y |
Copy Selection to + Register |
"+P |
Paste from + Register before Cursor |
"+p |
Paste from + Register after Cursor |
Keys | Action |
---|---|
* |
Search Forward for the identifier under Cursor |
# |
Search Backward for the identifier under Cursor |
/{pattern}<Enter> |
Search Forward for {pattern} |
/<Enter> |
Repeat Search Forward |
?{pattern}<Enter> |
Search Backward for {pattern} |
?<Enter> |
Repeat Search Backward |
n |
Repeat Search in the Same Direction |
N |
Repeat Search in the Opposite Direction |
:s/{pattern}/{replacement}/g<Enter> |
Search and Replace All {pattern} with {replacement} in Line |
:s/{pattern}/{replacement}/gc<Enter> |
Search and Replace All {pattern} with {replacement} in Line asking for confirmation (y/n/a/q) on each match |
:s//{replacement}/g<Enter> |
Repeat Search and Replace All but with new {replacement} in Line |
:s//{replacement}/gc<Enter> |
Repeat Search and Replace All but with new {replacement} in Line asking for confirmation (y/n/a/q) on each match |
:s [g][c]<Enter> |
Repeat Search and Replace in Line but add/remove g or c options |
& |
Repeat Search and Replace in Line without g or c options. Same as :s<Enter> . |
:%s/{pattern}/{replacement}/g<Enter> |
Search and Replace {pattern} with {replacement} in File |
:%s/{pattern}/{replacement}/gc<Enter> |
Search and Replace {pattern} with {replacement} in File asking for confirmation (y/n/a/q) on each match |
:%s//{replacement}/g<Enter> |
Repeat Search and Replace All but with new {replacement} in File |
:%s//{replacement}/gc<Enter> |
Repeat Search and Replace All but with new {replacement} in File asking for confirmation (y/n/a/q) on each match |
Ctrl + Shift + h |
Search and Replace in Multiple Files |
Keys | Action |
---|---|
% |
Jump to Next Parenthesis or Curly Bracket |
k , j (Except Insert/Replace Mode) |
Move Up or Down between Lines |
↑ , ↓ |
Move Up or Down between Lines |
h , l (Except Insert/Replace Mode) |
Move Left or Right in Line |
← , → |
Move Left or Right in Line |
0 |
Jump to First Character in Line |
^ |
Jump to First Non-Blank Character in Line |
{N}| |
Jump to Column {N} in Line |
{N}f{char} |
Jump to the {N} th occurrence of {char} to the Right in Line |
{N}F{char} |
Jump to the {N} th occurrence of {char} to the Left in Line |
{N}t{char} |
Jump till before the {N} th occurrence of {char} to the Right in Line |
{N}T{char} |
Jump till before the {N} th occurrence of {char} to the Left in Line |
{N}; |
Repeat Previous f , F , t , T Jump for {N} times in the Same Directinon |
{N}, |
Repeat Previous f , F , t , T Jump for {N} times in the Opposite Direction |
gg |
Jump to the First Line |
G |
Jump to the Last Line |
{N}G |
Jump to the {N} th Line |
{N}$ |
Jump to the end of {N} th Line |
H |
Jump to the top of Screen |
L |
Jump to the bottom of Screen |
M |
Jump to the middle of Screen |
zt |
Scroll Current Line to the top of Screen |
zb |
Scroll Current Line to the bottom of Screen |
zz |
Scroll Current Line to the middle of Screen |
Ctrl + b |
Scroll upwards by a Page |
Ctrl + f |
Scroll downwards by a Page |
Ctrl + u |
Scroll upwards by half a Window |
Ctrl + d |
Scroll downwards by half a Window |
:marks<Enter> |
List all the current Marks |
m{a-z} |
Set Mark {a-z} at Cursor for moving within File |
m{A-Z} |
Set Mark {A-Z} at Cursor for moving between Files |
'{a-z} |
Jump to Mark {a-z} within File |
'{A-Z} |
Jump to Mark {A-Z} in the File where it is set |
:delmarks {a-zA-Z}<Enter> |
Delete specified list of Marks from {a-zA-Z} |
'"" |
Jump to the position when last editing the File |
'.. |
Jump to the position of the last change in the File |
'' |
Jump to the position before the last jump |
Alt + ← |
Jump back to the positon before the last jump |
Alt + → |
Jump forward to the positon before the last jump |
Ctrl + Space |
Trigger Suggestions |
Ctrl + Shift + o |
Go to Symbol |
gO |
Go to Symbol under Cursor |
gh |
Show Hover for Symbol under Cursor |
gd |
Reveal Definition for Symbol under Cursor |
gD |
Peek Definition for Symbol under Cursor |
Ctrl + w gd |
Reveal Definition Aside Symbol under Cursor |
gf |
Reveal Declaration Symbol under Cursor |
gF |
Peek Declaration Symbol under Cursor |
Ctrl + w gf |
Reveal Declaration Aside Symbol under Cursor |
gH |
Peek References Symbol under Cursor |
Alt + Shift + h |
Show Call Hierarchy |
Tab |
Switch between Peek Editor and References List |
z= |
Open Quick Fix |
Prefix these with an operator like v
, c
, d
, or y
(Except Insert Mode).
Keys | Action |
---|---|
aw |
Full Word with leading or trailing Space |
iw |
Full Word without leading or trailing Space |
aW |
Full Word or several until and including leading or trailing Space |
iW |
Full Word or several until a leading or trailing Space |
as |
Full Sentence with leading or trailing Space |
is |
Full Sentence without leading or trailing Space |
aB |
From [{ to }] |
iB |
Within [{ and }] |
ab |
From [( to )] |
ib |
Within [( and )] |
at |
From Start Tag to End Tag e.g. <div> to </div> |
it |
Within Start Tag and End Tag |
a> |
From < to > e.g. <div> |
i> |
Within < and > |
a' |
Entire Single Quoted String |
i' |
Within a Single Quoted String |
a" |
Entire Double Quoted String |
i" |
Within a Double Quoted String |
a` |
Entire Backward Quoted String |
i` |
Within a Backward Quoted String |
Keys | Action |
---|---|
F2 |
Rename Symbol |
R |
Start Replace Mode |
V |
Select Line |
= |
Format Selection |
== |
Format Line |
gq{motion} |
Format Lines within {motion} |
gu{motion} |
Lowercase Lines within {motion} or Line |
gU{motion} |
Uppercase Lines within {motion} or Line |
g~{motion} |
Swap case of Lines within {motion} or Line |
gc |
Toggle Comment for Selection |
gcc |
Toggle Comment for Line |
Ctrl + / |
Toggle Comment for Selection or Line |
O |
Add Line Above |
o |
Add Line Below |
Alt + ↑ |
Move Line Above |
Alt + ↓ |
Move Line Below |
Shift + Alt + ↑ |
Copy Line Above |
Shift + Alt + ↓ |
Copy Line Below |
Ctrl + Alt + ↑ |
Add Cursor Above |
Ctrl + Alt + ↓ |
Add Cursor Below |
:reg<Enter> |
List all the current Registers |
"{a-z} |
Use Register {a-z} for the next Copy/Delete/Paste |
q{a-z} |
Start recording a macro in Register {a-z} |
q{A-Z} |
Start recording a macro and append to Register {a-z} |
q |
Stop recording a macro |
Q |
Replay last recorded macro |
{N}@{a-z} |
Execute macro in Register {a-z} for {N} times |
{N}@@ |
Execute previous @{a-z} for {N} times |
Ctrl + r {register} (Insert mode only) |
Insert the content of a Register |
Ctrl + w (Insert mode only) |
Delete word before the Cursor |
Ctrl + u (Insert mode only) |
Delete all entered characters or all characters on the Line before the Cursor |
Ctrl + t (Insert mode only) |
Increase Indent for Line |
Ctrl + d (Insert mode only) |
Decrease Indent for Line |
>> |
Increase Indent for Line |
<< |
Decrease Indent for Line |
>{motion} |
Increase Indent for {motion} |
<{motion} |
Decrease Indent for {motion} |
J |
Join Lines in the Selection |
gJ |
Join Lines in the Selection without Space |
{N}J |
Join Line with the next {N-1} Lines |
{N}gJ |
Same as {N}J but without Space |
]p |
Paste after Cursor but adjust Indent to match Line |
[p |
Paste before Cursor but adjust Indent to match Line |
gp |
Paste after Cursor and leave Cursor after the Pasted Text |
gP |
Paste before Cursor and leave Cursor after the Pasted Text |
{N}r{char} |
Replace {N} characters with {char} |
{N}s |
Change {N} characters |
{N}yy |
Copy {N} Lines |
{N}Y |
Copy {N} Lines |
{N}cc |
Change {N} Lines |
{N}S |
Change {N} Lines |
{N}C |
Change {N} Lines |
{N}dd |
Delete {N} Lines |
{N}D |
Delete {N} Lines |
{N}. |
Repeat Previous Change {N} times |
{N}u |
Undo Previous {N} Changes |
{N}Ctrl + r |
Redo Previous {N} undone Changes |