✨ A nvim config for both neovim and vscode. The biggest difference from the other configs, such as LazyVim, is that this config keeps neovim as a simple editor rather than IDE. Let vscode focus on being IDE, and let neovim focus on editing.
# 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
# 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
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 <A-I>
, to <C-i>
in neovim,
and then map ctrl+i
to send <A-I>
key sequence in your terminal setting.
For more info :h tui-modifyOtherKeys
and xterm-modified-keys
My own windows terminal setting is here.
Make sure you have added following settings to your settings.json,
"extensions.experimental.affinity": {
"asvetliakov.vscode-neovim": 1
},
"vscode-neovim.ctrlKeysForInsertMode": [
"a",
"c",
"d",
"h",
"j",
"o",
"r",
"t",
"u",
"w",
// all above are default keys
"e",
"k",
"n"
],
"vscode-neovim.ctrlKeysForNormalMode": [
"a",
"b",
"c",
"d",
"e",
"f",
"h",
"i",
"j",
"l",
"o",
// "r",
// "t",
"u",
"v",
"w",
"x",
"y",
// "z",
"/",
"]",
"right",
"left",
"up",
"down",
"backspace",
"delete",
"n"
],
and also add all the keybindings to your keybindings.json
Neovim Keys | VSCode Keys | Mode | Description |
---|---|---|---|
SPC e |
Ctrl +Shift +E |
N | Open or focus explorer |
j |
j |
Explorer | Up |
k |
k |
Explorer | Down |
h |
h |
Explorer | Collapse |
l |
l |
Explorer | Expand or open |
a |
a |
Explorer | Add new file |
A |
A |
Explorer | Add new directory |
r |
r |
Explorer | Rename |
x |
x |
Explorer | Cut |
y |
y |
Explorer | Copy |
p |
p |
Explorer | Paste |
d |
d |
Explorer | Delete |
c |
c |
Explorer | Copy path |
o |
o |
Explorer | Open by system |
/ |
/ |
Explorer | Filter |
? |
- | Explorer | Help |
Neovim Keys | VSCode Keys | Mode | Description |
---|---|---|---|
H |
H |
N | Previous file |
L |
L |
N | Next file |
SPC TAB |
Ctrl +TAB |
N | Switch file |
Ctrl +S |
Ctrl +S |
N | Save file |
SPC bd |
Ctrl+W q |
N | Close file |
Neovim Keys | VSCode Keys | Mode | Description |
---|---|---|---|
Tab |
Tab |
N | Next window |
Shift +Tab |
Shift +Tab |
N | Previous window |
Ctrl +W s |
Ctrl +W s |
N | Horizontal split window |
Ctrl +W v |
Ctrl +W v |
N | Vertical split window |
Ctrl +W = |
Ctrl +W = |
N | Resize windows |
Ctrl +W o |
Ctrl +W o |
N | Close other windows |
Ctrl +W q |
Ctrl +W q |
N | Close {count} -th windows, default current |
Tips:
- The
buffer
in Neovim is similar to theeditor
in VSCode.- The
window
in Neovim is similar to theeditor group
in VSCode.- They are just similar rather than equal.
Use Search if the target positon is unknown or too far.
Neovim Key | VSCode Key | Mode | Description |
---|---|---|---|
/ |
/ |
N | Search forward in file |
? |
? |
N | Search backward in file |
* |
* |
N V | Search forward for the word nearest to the cursor in file |
# |
# |
N V | Search backward for the word nearest to the cursor in file |
n |
n |
n | Search forwar for last pattern in file |
N |
N |
N | Search backward for last pattern in file |
SPC / |
Ctrl +Shift +F |
N V | Search in workspace |
SPC f |
Ctrl +P |
N | Search files in workspace |
SPC r |
Ctrl +R |
N | Search recently opened files |
SPC sw |
- | N V | Search based on word in workspace |
SPC sm |
Side Bar | N | Search marks |
SPC st |
Side Bar | N | Search todos |
SPC ss |
Ctrl +Shift +O |
N | Search symbols in file |
SPC sS |
Ctrl +T |
N | Search symbols in workspace |
gd |
gd |
N | Go to definition |
gy |
gy |
N | Go to type definition |
gr |
gr |
N | Go to reference |
gi |
gi |
N | Go to implementation |
Ctrl +/ |
- | Telescope | Help |
Tips:
- For details of vim regular expression, see
:h pattern
- For fzf fuzzy search syntax, see
:h telescope-fzf-native.nvim
Use Scroll if the target position is roughly known.
Neovim Keys | VSCode Keys | Mode | Description |
---|---|---|---|
Ctrl +D |
Ctrl +D |
N | Scroll down half screen |
Ctrl +U |
Ctrl +U |
N | Scroll up half screen |
Ctrl +F |
Ctrl +F |
N | Scroll down full screen |
Ctrl +B |
Ctrl +B |
N | Scroll up full screen |
gg |
gg |
N | Go to first line |
G |
G |
N | Go to {count} -th line , default last line |
zz |
zz |
N | Scroll to leave current line at center of screen |
zt |
zt |
N | Scroll to leave current line at top of screen |
zb |
zb |
N | Scroll to leave current line at bottom of screen |
Alt +F |
Alt+F |
N | Scroll left |
Alt +B |
Alt+B |
N | Scroll right |
zs |
- | N | Scroll to leave current column at left of screen |
Use Motion if the target position is exactly known.
Key | Mode | Description |
---|---|---|
h |
N V | Move left |
l |
N V | Move right |
j |
N V | Move up |
k |
N V | Move down |
0 |
N V | Move to the start of the line |
$ |
N V | Move to the end of the line |
Ctrl +A |
I | Move to the start of the line |
Ctrl +E |
I | Move to the end of the line |
f {char} |
N V | Jump to the next position of {char} |
F {char} |
N V | Jump to the previous position of {char} |
t {char} |
N V | Jump to the next position before {char} |
T {char} |
N V | Jump to the previous position after {char} |
m {mark} |
N | Set a mark |
` {mark} |
N | Jump to mark |
Ctrl +O |
N | Go to older cursor position in jump list (not a motion) |
Ctrl +I |
N | Go to newer cursor position in jump list (not a motion) |
g; |
N | Go to older cursor position in change list (not a motion) |
g, |
N | Go 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 ) |
Motions | Description |
---|---|---|
q |
Quote surround, "" '' `` |
|
b |
Bracket surround, {} [] () <> |
|
t |
Tag surround, <tag></tag> |
|
{char} |
Character surround, support punction and digit | |
? |
User prompt surround | |
w |
w b e |
word |
W |
W B E |
WORD |
p |
{ } |
Paragraph |
l |
Line | |
e |
Entire file | |
g |
[g ]g |
Git change hunk |
i |
[i ]i |
Indent |
o |
Block/Loop/Condition | |
a |
[a ]a |
Argument |
f |
Function call surround | |
F |
[f ]f |
Function |
T |
[t ]t |
Type definition |
c |
[c ]c |
Comment |
- | [d ]d [e ]e [w ]w |
Diagnostics/Error/Warning |
S (not text object) |
; , |
Parent treesitter node |
Visual Selection Keys | Mode | Description |
---|---|---|
v |
N V | Charwise visual selection |
V |
N V | Linewise visual selection |
Ctrl +V |
N V | Blockwise visual selection |
o |
V | Move cursor to begin or end of selection region, so you can tweek the range manually |
a /i {textobj} |
V | Expand selection to fit outter text object, else select next text object |
an /in {textobj} |
V | Select next/previous text object |
aN /iN {textobj} |
V | Select next/previous text object |
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
Operator | Mode | Description | Comment |
---|---|---|---|
gu |
N V | Make text lowercase | guu =0gu$ , vu =vgu |
gU |
N V | Make text uppercase | gUU =0gU$ , vU =vgU |
g~ |
N V | Switch case of text | g~~ =0g~$ , v~ =vg~ , ~ =g~l |
c |
N V | Change text | Alt +c ="_c , cc =0c$ , C =c$ , s =cl |
d |
N V | Delete text | Alt +d ="_d , dd =0v$d , D =d$ , x =dl , X =dh |
y |
N V | Yank (Copy) text | yy =0v$y , Y =y$ |
v |
N | Start charwise visual | v$ will cover the EOL |
Normal Key | Mode | Description |
---|---|---|
ESC |
ALL | Return to normal mode |
ys {motion} {char} |
N V | Add surround around {motion} with {char} |
cs {char1} {char2} |
N | Change the surrounding pair {char} with {char2} |
ds {char} |
N | Delete the surrounding pair {char} |
r {char} |
N V | Replace the character under the cursor with {char} |
J |
N V | Join lines into one line |
< |
N V | Shift lines left |
> |
N V | Shift lines right |
Alt +J |
I, N, V | Move line Down |
Alt +K |
I, N, V | Move line Up |
Ctrl +A |
N | Add to the number under cursor |
Ctrl +X |
N | Subtract from the number under cursor |
] SPC |
N | Add empty line below |
[ SPC |
N | Add empty line above |
Insert Key | Mode | Description |
---|---|---|
i |
N | Insert before the cursor |
a |
N | Insert after the cursor |
I |
N | Insert before the first non-blank in the line |
A |
N | Insert before the end of the line |
o |
N | Insert a new line below the cursor |
O |
N | Insert a new line above the cursor |
Ctrl +O |
I | Execute one command then return to Insert mode |
Ctrl +H |
I | Delete left |
Ctrl +W |
I | Delete left word |
Ctrl +U |
I | Delete all left |
Ctrl +D |
I | Delete right |
Alt +D |
I | Delete right word |
Ctrl +K |
I | Delete all right |
Ctrl +J |
I | New line |
Key | Mode | Description |
---|---|---|
" {register} {yank or put} |
N V | Use {register} to yank or paste |
Ctrl +R {register} |
I | Paste text from {register} |
y |
N V | Copy text |
p |
N V | Paste text after cursor |
P |
N | Paste text before cursor |
gp |
N | Paste text below current line |
gp |
N | Paste text above current line |
zp |
N V | Paste last yanked text after cursor |
zP |
N | Paste last yanked text before cursor |
zgp |
N | Paste last yanked text below current line |
zgp |
N | Paste last yanked text above current line |
[p |
N | Cycle forward through yank history |
]p |
N | Cycle backward through yank history |
Ctrl +V |
I | Paste last yanked |
SPC sy |
N | Search yank history |
Tips
Commonly used registers (With yanky installed)
"
: laste deleted, changed or yanked0
: last yanked1-9
: history of deleted, changed or yanked.
: last inserted text:
: last command line/
: last search patternUse
`[
or`]
to jump to the start or end of last changed or yanked text.
Key | Mode | Description |
---|---|---|
. |
N | Repeat last change |
q {register} |
N | Record typed characters into register, q again to stop |
@ {register} |
N | Execute the contents of register |
@@ |
N | Repeat Previous @ |
Q |
N | Repeat the last recorded register |
Ctrl +J |
N | Add cursor downward |
Ctrl +K |
N | Add cursor upward |
Ctrl +N |
N | Add cursor at next find match |
SPC ms |
N | Add cursor at selected position |
SPC mw |
N | Add cursor at selected position that match the word under cursor |
Key | Mode | Description |
---|---|---|
u |
N | Undo |
U |
N | Redo |
Ctrl +Z |
N I | VSCode Undo |
SPC su |
N | Search undo history |
Key | Mode | Description |
---|---|---|
Ctrl +N |
I | Select next item, or show completion menu |
Ctrl +P |
I | Select previous item, or show completion menu |
CR |
I | Confirm selected item and insert it |
Shift +CR |
I | Confirm selected item and replace with it |
Ctrl +CR |
I | Hide completion menu and insert enter |
Tab |
I | jump to next snippet placeholder |
Shift +Tab |
I | jump to previous snippet placeholder |
K |
N | Signature infomation |
F2 |
N | Rename symbol |
Ctrl +. |
N | Code Action |
Ctrl +/ |
I N V | Comment code |
Alt +Shift +F |
I N V | Format code |
Key | Mode | Description |
---|---|---|
Ctrl +` |
N | Toggle terminal |
SPC n |
N | Toggle output |
Alt +Z |
N | Toggle wrap |
za |
N | Toggle fold |
ga |
N | Unicode point |
g8 |
N | utf-8 encoding |