Nvim

March 28, 2026 Β· View on GitHub

Nvim

✨ A nvim config for both neovim and vscode. Now this config is based on LazyVim.

lisence stars open_issues tag last_commit

nvim1 nvim2


Installation

Requirements

Windows

# required
Move-Item $env:LOCALAPPDATA\nvim $env:LOCALAPPDATA\nvim.bak
# optional but recommended
Move-Item $env:LOCALAPPDATA\nvim-data $env:LOCALAPPDATA\nvim-data.bak
# clone
git clone https://github.com/mrbeardad/nvim $env:LOCALAPPDATA\nvim
# start and install plugins automatically
nvim

Linux

# required
mv ~/.config/nvim{,.bak}
# optional but recommended
mv ~/.local/share/nvim{,.bak}
mv ~/.local/state/nvim{,.bak}
mv ~/.cache/nvim{,.bak}
# clone
git clone https://github.com/LazyVim/starter ~/.config/nvim
# start and install plugins automatically
nvim

Configuration

Make sure you have added following settings to your vscode settings.json,

  "extensions.experimental.affinity": {
    "asvetliakov.vscode-neovim": 1
  },

  "vscode-neovim.ctrlKeysForInsertMode": ["w", "a", "e", "o", "h", "u", "d", "k", "r", "n"],
  "vscode-neovim.ctrlKeysForNormalMode": ["w", "d", "u", "b", "o", "i", "a", "x", "v", "r", "j", "n"],

and also add all the keybindings to your keybindings.json

In most of terminals, <C-S-*> and <C-*> have the same key sequence. To distinguish them, map ctrl+shift+* to send <C-S-*> key sequence in your terminal setting. For detail see here

For historical reason, <Tab> and <C-i> have the same key sequence in most of terminals. To distinguish them, you could map another key, say <M-I>, to <C-i> in neovim, and then map ctrl+i to send <M-I> key sequence in your terminal setting. For more info :h tui-modifyOtherKeys and xterm-modified-keys

My own windows terminal setting is here.

Keymaps

Editor

Neovim KeysVSCode KeysModeDescription
Space eCtrl+Shift+ENOpen or focus explorer
jjExplorerUp
kkExplorerDown
hhExplorerCollapse
llExplorerExpand or open
aaExplorerAdd new file/directory
rrExplorerRename
yyExplorerCopy
ppExplorerPaste
ddExplorerDelete
ccExplorerCopy path
ooExplorerOpen by system
//ExplorerFilter
?ExplorerHelp
Neovim KeysVSCode KeysModeDescription
HHNPrevious file
LLNNext file
Space TabCtrl+TabNSwitch file
Ctrl+SCtrl+SNSave file
Space bdCtrl+W qNClose file
Neovim KeysVSCode KeysModeDescription
TabTabNNext window
Shift+TabShift+TabNPrevious window
Ctrl+W sCtrl+W sNHorizontal split window
Ctrl+W vCtrl+W vNVertical split window
Ctrl+W =Ctrl+W =NResize windows
Ctrl+W oCtrl+W oNClose other windows
Ctrl+W cCtrl+W cNClose {count}-th windows, default current

Tips:

  1. The buffer in Neovim is similar to the editor in VSCode.
  2. The window in Neovim is similar to the editor group in VSCode.
  3. They are just similar rather than equal.

Use Search if the target positon is unknown or too far.

Neovim KeyVSCode KeyModeDescription
//, Ctrl+FNSearch forward in file
??NSearch backward in file
**N VSearch forward for the word nearest to the cursor in file
##N VSearch backward for the word nearest to the cursor in file
nnnSearch forwar for last pattern in file
NNNSearch backward for last pattern in file
Space /Ctrl+Shift+FN VSearch in workspace
Space SpaceCtrl+PNSearch files in workspace
Space rCtrl+K Ctrl+RNSearch recently opened files
Space smSide BarNSearch marks
Space stSide BarNSearch todos
Space ssCtrl+Shift+ONSearch symbols in file
Space sSCtrl+TNSearch symbols in workspace
gdgdNGo to definition
gygyNGo to type definition
grgrNGo to reference
Ctrl+/PickerHelp

Tips:

  1. For details of vim regular expression, see :h pattern
  2. For fzf fuzzy search syntax, see Fzf Search Syntax

Scroll

Use Scroll if the target position is roughly known.

Neovim KeysVSCode KeysModeDescription
Ctrl+DCtrl+DNScroll down half screen
Ctrl+UCtrl+UNScroll up half screen
Ctrl+FNScroll down full screen
Ctrl+BCtrl+BNScroll up full screen
ggggNGo to first line
GGNGo to {count}-th line, default last line
zzzzNScroll to leave current line at center of screen
MMNMove cursor to center of screen
Alt+FAlt+FNScroll left
Alt+BAlt+FNScroll right

Motion

Use Motion if the target position is exactly known.

KeyModeDescription
hN VMove left
lN VMove right
jN VMove up
kN VMove down
0N VMove to the start of the line
$N VMove to the end of the line
Ctrl+AIMove to the start of the line
Ctrl+EIMove to the end of the line
f {char}N VJump to the next position of {char}
F {char}N VJump to the previous position of {char}
t {char}N VJump to the next position before {char}
T {char}N VJump to the previous position after {char}
m {mark}NSet a mark
` {mark}NJump to mark
Ctrl+ONGo to older cursor position in jump list (not a motion)
Ctrl+INGo to newer cursor position in jump list (not a motion)
g;NGo to older cursor position in change list (not a motion)
g,NGo to newer cursor position in change list (not a motion)

Tips:

  • Jump is command that normally moves the cursor several lines away. If you make the cursor "jump", the position of the cursor before the jump is remembered in jump list. For details, see :h jump-motions
Text Object (omit a/i)MotionsDescription
?User prompt surround
{char}Character surround (support punction and digit)
qQuote surround, "" '' ``
bBracket surround, {} [] () <>
tTag surround, <tag></tag>
w, ew b eword
W, EW B EWORD
p{ }Paragraph
gEntire file
i[i ]iIndent
oBlock/Loop/Condition
a[a ]aArgument
f[f ]fFunction
uFunction usage (calling)
c[c ]cType definition
[d ]d [e ]e [w ]wDiagnostics/Error/Warning
[h ]hHunks (Git change or diff)
Visual Selection KeysModeDescription
vN VCharwise visual selection
VN VLinewise visual selection
Ctrl+VN VBlockwise visual selection
oVMove cursor to begin or end of selection region, so you can tweek the range manually
a/i {textobj}VExpand selection to fit outter text object, else select next text object
an/in {textobj}VSelect next/previous text object
al/il {textobj}VSelect next/previous text object

Operation

Add/Change/Delete

Tips:

  • Operator + [count] Motion = Do operator for all text from the start position to the end position
  • Operator + [count] Text-Object = Do operator for all text in text object
  • {Visual} Operator = Do operator for visual selected text
OperatorModeDescriptionComment
guN VMake text lowercaseguu=0gu$, vu=vgu
gUN VMake text uppercasegUU=0gU$, vU=vgU
g~N VSwitch case of textg~~=0g~$, v~=vg~, ~=g~l
cN VChange textAlt+c="_c, cc=0c$, C=c$, s=cl
dN VDelete textAlt+d="_d, dd=0v$d, D=d$, x=dl, X=dh
yN VYank (Copy) textyy=0v$y, Y=y$
vNStart charwise visualv$ will cover the EOL
Normal KeyModeDescription
EscALLReturn to normal mode
ys {motion} {char}N VAdd surround around {motion} with {char}
cs {char1} {char2}NChange the surrounding pair {char} with {char2}
ds {char}NDelete the surrounding pair {char}
r {char}N VReplace the character under the cursor with {char}
JN VJoin lines into one line
<N VShift lines left
>N VShift lines right
Alt+JI, N, VMove line Down
Alt+KI, N, VMove line Up
Ctrl+ANAdd to the number under cursor
Ctrl+XNSubtract from the number under cursor
] SpaceNAdd empty line below
[ SpaceNAdd empty line above
Insert KeyModeDescription
iNInsert before the cursor
aNInsert after the cursor
INInsert before the first non-blank in the line
ANInsert before the end of the line
oNInsert a new line below the cursor
ONInsert a new line above the cursor
Ctrl+OIExecute one command then return to Insert mode
Ctrl+HIDelete left
Ctrl+WIDelete left word
Ctrl+UIDelete all left
Ctrl+DIDelete right
Alt+DIDelete right word
Ctrl+KIDelete all right

Yank

KeyModeDescription
" {register} {yank or put}N VUse {register} to yank or paste
Ctrl+R {register}IPaste text from {register}
yN VCopy text
pN VPaste text after cursor
PNPaste text before cursor
gpNPaste text below current line
gPNPaste text above current line
zpN VPaste last yanked text after cursor
zPNPaste last yanked text before cursor
zgp|gzpNPaste last yanked text below current line
zgP|gzPNPaste last yanked text above current line
[y|[pNCycle forward through yank history
]y|]pNCycle backward through yank history
Ctrl+CVCopy (VSCode only)
Ctrl+VI VPaste last yanked
Space pNSearch yank history

Tips

  • Commonly used registers (With yanky installed)
    1. ": laste changed, deleted or yanked
    2. 1-9: history of deleted, changed or yanked
    3. 0: last yanked
    4. -: last short changed or deleted (didn't across multiple lines)
    5. .: last inserted text
    6. :: last command line
    7. /: last search pattern
  • Use `[ or `] to jump to the start or end of last changed or yanked text.

Repeat

KeyModeDescription
.NRepeat last change
q {register}NRecord typed characters into register, q again to stop
@ {register}NExecute the contents of register
@@NRepeat Previous @
QNRepeat the last recorded register
Ctrl+JNAdd cursor downward
Ctrl+Shift+JNMove cursor down
Ctrl+KNAdd cursor upward
Ctrl+Shift+KNMove cursor up
Ctrl+NNAdd selection at next find match
Ctrl+Shift+NNMove selection to next find match
Ctrl+Shift+LNAdd selection at all find match
Space mwNAdd cursor at selected word
Space mmNAdd cursor at selected pattern match

Tips

There is more than one method for complex repetitive editing: (from easy to difficult)

  1. Dot repeat .
  2. Multiple cursors
  3. Substitute command :%s/pat/repl/[flag]
  4. Macro q/@

Undo

KeyModeDescription
uNUndo
Ctrl+RNRedo
Ctrl+ZIUndo
Space suNSearch undo history

Language

KeyModeDescription
Ctrl+NISelect next item, or show completion menu
Ctrl+PISelect previous item, or show completion menu
TabIConfirm selected item and insert it
Shift+TabIConfirm selected item and replace with it
TabIJump to next snippet placeholder
Shift+TabIJump to previous snippet placeholder
KNSignature infomation
F2NRename symbol
Ctrl+.NCode Action
Ctrl+/I N VComment code
Alt+Shift+FI N VFormat code

Misc

KeyModeDescription
Ctrl+`NToggle terminal
Space nNToggle output
Alt+ZNToggle wrap
zaNToggle fold
gaNUnicode point
g8Nutf-8 encoding