bindings - theol0403/vscode-neovim GitHub Wiki

Table of Contents

These are the default commands and bindings available for file/scroll/window/tab management.

💡 "With bang" refers to adding a "!" to the end of a command.

VSCode specific bindings

Editor command

Key VSCode Command
= / == editor.action.formatSelection
gh / K editor.action.showHover
gd / C-] editor.action.revealDefinition
Also works in vim help.
gf editor.action.revealDeclaration
gH editor.action.referenceSearch.trigger
gO workbench.action.gotoSymbol
C-w gd / C-w gf editor.action.revealDefinitionAside
gD editor.action.peekDefinition
gF editor.action.peekDeclaration
Tab togglePeekWidgetFocus
Switch between peek editor and reference list.
C-n / C-p Navigate lists, parameter hints, suggestions, quick-open, cmdline history, peek reference list

💡 To specify the default peek mode, modify editor.peekWidgetDefaultFocus in your settings.

Explorer/list navigation

Key VSCode Command
j / k list.focusDown/Up
h / l list.collapse/select
Enter list.select
gg list.focusFirst
G list.focusLast
o list.toggleExpand
C-u / C-d list.focusPageUp/Down
/ / Escape list.toggleKeyboardNavigation

💡 To enable explorer list navigation, add "workbench.list.automaticKeyboardNavigation": false to your settings.json.

Explorer file manipulation

Key VSCode Command
r renameFile
d deleteFile
y filesExplorer.copy
x filesExplorer.cut
p filesExplorer.paste
v explorer.openToSide
a explorer.newFile
A explorer.newFolder

File management

Command Description
e[dit] / ex Open quickopen.
With filename, e.g. :e $MYVIMRC: open the file in new tab. The file must exist.
With bang: revert file to last saved version.
With filename and bang e.g. :e! $MYVIMRC: close current file (discard any changes) and open the file. The file must exist.
ene[w] Create new untitled document in vscode.
With bang: close current file (discard any changes) and create new document.
fin[d] Open vscode's quick open window. Arguments and count are not supported.
w[rite] Save current file. With bang: open 'save as' dialog.
sav[eas] Open 'save as' dialog.
wa[ll] Save all files.
q[uit] / C-w q / C-w c / ZQ Close the active editor. With bang: revert changes and close the active editor.
wq / ZZ Save and close the active editor.
qa[ll] Close all editors, but don't quit vscode. Acts like qall!, so beware for nonsaved changes.
wqa[ll] / xa[ll] Save all editors & close.

Tab management

Command Description
tabe[dit] Similar to e[dit]. Open quickopen.
With argument: open the file in new tab.
tabnew Open new untitled file.
tabf[ind] Open quickopen window.
tab/tabs Not supported. Doesn't make sense with vscode.
tabc[lose] Close active editor (tab).
tabo[nly] Close other tabs in vscode group (pane). This differs from vim where a tab is a like a new window, but doesn't make sense in vscode.
tabn[ext] / gt Switch to next (or count tabs if argument is given) in the active vscode group (pane).
tabp[revious] / gT Switch to previous (or count tabs if argument is given) in the active vscode group (pane).
tabfir[st] Switch to the first tab in the active editor group.
tabl[ast] Switch to the last tab in the active editor group.
tabm[ove] Not supported yet.

Buffer/window management

Command Key Description
sp[lit] C-w s Split editor horizontally.
With argument: open the specified file, e.g :sp $MYVIMRC. File must exist.
vs[plit] C-w v Split editor vertically.
With argument: open the specified file. File must exist.
new C-w n Like sp[lit] but create new untitled file if no argument given.
vne[w] Like vs[plit] but create new untitled file if no argument given.
C-w = Align all editors to have the same width.
C-w _ Toggle maximized editor size. Pressing again will restore the size.
[count] C-w + Increase editor height by (optional) count.
[count] C-w - Decrease editor height by (optional) count.
[count] C-w > Increase editor width by (optional) count.
[count] C-w < Decrease editor width by (optional) count.
on[ly] C-w o Without bang: merge all editor groups into the one. Don't close editors.
With bang: close all editors from all groups except current one.
C-w j/k/h/l Focus group below/above/left/right.
C-w C-j/i/h/l Move editor to group below/above/left/right.
Note: C-w C-i moves editor up. Ideally it should be C-w C-k but vscode has many commands mapped to C-k [key] and doesn't allow to use C-w C-k without unbinding them first.
C-w J/K/H/L Move whole editor group below/above/left/right.
C-w w or C-w C-w Focus next group. The behavior may differ than in vim.
C-w W or C-w p Focus previous group. The behavior may differ than in vim. C-w p is completely different than in vim.
C-w b Focus last editor group (most bottom-right).
C-w r/R/x Not supported, use C-w C-j and similar to move editors.

💡 Split size distribution is controlled by workbench.editor.splitSizing setting. By default, it's distribute, which is equal to vim's equalalways and eadirection = 'both' (default).

To use VSCode command 'Increase/decrease current view size' instead of separate bindings for width and height:

  • workbench.action.increaseViewSize
  • workbench.action.decreaseViewSize
Copy this into init.vim
function! s:manageEditorSize(...)
    let count = a:1
    let to = a:2
    for i in range(1, count ? count : 1)
        call VSCodeNotify(to ==# 'increase' ? 'workbench.action.increaseViewSize' : 'workbench.action.decreaseViewSize')
    endfor
endfunction

" Sample keybindings. Note these override default keybindings mentioned above.
nnoremap <C-w>> <Cmd>call <SID>manageEditorSize(v:count, 'increase')<CR>
xnoremap <C-w>> <Cmd>call <SID>manageEditorSize(v:count, 'increase')<CR>
nnoremap <C-w>+ <Cmd>call <SID>manageEditorSize(v:count, 'increase')<CR>
xnoremap <C-w>+ <Cmd>call <SID>manageEditorSize(v:count, 'increase')<CR>
nnoremap <C-w>< <Cmd>call <SID>manageEditorSize(v:count, 'decrease')<CR>
xnoremap <C-w>< <Cmd>call <SID>manageEditorSize(v:count, 'decrease')<CR>
nnoremap <C-w>- <Cmd>call <SID>manageEditorSize(v:count, 'decrease')<CR>
xnoremap <C-w>- <Cmd>call <SID>manageEditorSize(v:count, 'decrease')<CR>

Insert mode special keys

Enabled by useCtrlKeysForInsertMode (default true).

Refer to vim manual for their use.

  • C-c
  • C-o
  • C-u
  • C-w
  • C-h
  • C-t
  • C-d
  • C-j
  • C-a
  • C-r

Normal mode control keys

Enabled by useCtrlKeysForNormalMode (default true).

Refer to vim manual for their use.

  • C-a
  • C-b
  • C-c
  • C-d
  • C-e
  • C-f
  • C-i
  • C-o
  • C-r
  • C-u
  • C-v
  • C-w
  • C-x
  • C-y
  • C-z
  • C-]
  • C-j
  • C-k
  • C-l
  • C-h
  • C-/

Cmdline special keys

Always enabled.

Refer to vim manual for their use.

  • C-h
  • C-w
  • C-u
  • C-r (including C-rC-w and others)
  • C-n
  • C-p
  • C-l
  • C-g
  • C-t
  • Tab
⚠️ **GitHub.com Fallback** ⚠️