Onivim 2 User Manual

Onivim 2 User Manual

  • Early Access
  • About
  • Timeline
  • Docs

›Configuration

Getting Started

  • Why Onivim?
  • Installation
  • Vim Differences
  • Tips for Vim Users
  • Tips for VSCode Users
  • Modal Editing 101

Basic Usage

  • Moving Around
  • Editing and Deleting Text
  • Visual Mode (Selection)
  • Working with Files
  • Formatting
  • Language Features
  • Command Line
  • Integrated Terminal
  • Emmet
  • Snippets

Configuration

  • Settings
  • Key Bindings
  • Extensions

Languages

  • Reason & OCaml
  • ReScript
  • Python
  • Go
  • Java
  • C / C++
  • C#
  • Rust

For Developers

  • Architecture
  • Building from Source
  • How to Contribute
  • Style Guide
  • License Key Bounty

Other

  • FAQ
  • Appendix A: v2 Design Doc
  • Appendix B: More Resources
Edit

Key Bindings

Onivim's keyboard configuration is designed to be mostly compatible with VSCode's Key Bindings.

Editing the keybindings

  • Press Command+Shift+P (Mac) or Control+Shift+P (Windows, Linux) to bring up the command palette
  • Select Preferences: Open keybindings File

Keybinding Format

Keybindings are defined as a JSON array, like:

[
  { "key": "<C-P>", "command": "workbench.action.quickOpen", "when": "editorTextFocus" }
]

Each rule consists of:

  • A key that describes the pressed keys

NOTE: Today, our key format is expressed as a Vim-style key-binding. Our plan, though, is to support both Vim-style (<C-K>) and VSCode-style key specifies (ctrl+k)

  • A command containing the identifier of the command to execute
  • An optional when clause containing a boolean expression that will be evaluated depending on the current editor state.

When a key is pressed:

  • The rules are evaluated from bottom to top
  • The first rule that matches, both the key and in terms of when is accepted
  • If a rule is found and has a command set, the command is executed.
  • If no matching rules are found, we pass the input key through to libvim to be handled by Vim.

There are a set of default rules provided by Onivim, but the customized rules are appended to the bottom - thus, user key bindings are executed first.

key format

The key parameter supports both Vim style and VSCode style key bindings.

Remaps

Remaps can also be specified via the same keybindings configuration file.

Remapping keys tend to be more natural for users coming from Vim, and they allow matching a key sequence and then producing a new set of key presses.

Remaps require 3 properties:

  • from - a key, specified in the same format as the key parameter
  • to - a key, specified in the same format as the key parameter
  • when - a context clause describing when the remapping should take effect.

An example of a remap would be:

{ "from": "jj", "to": "<esc>", "when": "editorTextFocus && insertMode" }

(which is functionally equivalent to :inoremap jj <ESC>)

Vim style

Vim-style keybindings are surrounded by < and >, and allow the following modifiers:

ModifierDescriptionExample
C-Control key<C-P>
S-Shift key<S-P>
A-Alt key<A-P>
D-Command key<D-P>

Note: A difference between Vim and Onivim is that D- also handles the 'Meta' and 'Win' keys on Linux and Windows, respectively

Modifiers may be combined, for example:

[
  { "key": "<C-S-P>", "command": "workbench.action.quickOpen", "when": "editorTextFocus" }
]

The <C-S-P> key binding would require the Control, Shift, and P keys to be pressed.

VSCode style

VSCode-style keybindings feature friendly names, like:

ModifierDescriptionExample
Ctrl+Control keyCtrl+P
Shift+Shift keyShift+P
Alt+Alt keyAlt+J
Meta+Meta/Command/Windows key
Cmd+Same as aboveCmd+P
Win+Same as aboveWin+P

Key Sequences

Onivim supports binding to key sequences, which require multiple key-presses in succession to engage.

Example:

  { "key": "jk", "command": "vim.esc", "when": "insertMode" }

This would require a key-press of 'j', followed by 'k'.

command arguments

when clause contexts

Onivim 2 gives you control over when key bindings are enabled through the when clause.

Conditional operators

For conditional expressions, you can use the following conditional operators:

OperatorSymbolExample
Or||listFocus || textInputFocus
And&&insertMode && suggestWidgetVisible

Expressions may be grouped with (), for example:

(editorTextFocus && !insertMode) || suggestWidgetVisible

Contexts

Common contexts with VSCode:

Context NameTrue When
editorFocusAn editor has focus
editorTextFocusAn editor has focus
hasSearchResultsSearch results are available
inSnippetModeA snippet session is currently active
renameInputVisibleThe rename input is visible
suggestWidgetVisibleThe suggest widget (auto-completion) is visible
textInputFocusA text input area has focus
terminalFocusA terminal has focus

The activeViewlet context key corresponds to the id of the open sidebar pane:

  • workbench.view.explorer - File Explorer
  • workbench.view.extensions - Extensions
  • workbench.view.scm - SCM
  • workbench.view.search - Search

The editorLangId context key corresponds to the language identifier of the active editor (the same value shown in the statusbar), and can be combined with other context keys, like: 'when': 'editorFocus && editorLangId == typescript'

Onivim-specific contexts:

Context NameTrue When
insertModeThe active editor is in insert mode
normalModeThe active editor is in normal mode
visualModeThe active editor is in visual mode
sneakModeSneak mode is active
commandLineFocusThe Vim commandline is open
listFocusA list of items (like a pop-up menu) is focused
sideBarFocusThe sidebar has focus visible
sideBarVisibleThe sidebar is visible
paneFocusThe bottom pane has focus
vimListNavigationInside a Vim-navigable list
vimTreeNavigationInside the file explorer

Commands

Default Key BindingDescriptionCommand
Command+Shift+P / Control+Shift+PShow Command Paletteworkbench.action.showCommands
Command+Shift+M / Control+Shift+MShow Problems Paneworkbench.actions.view.problems
Command+P / Control+PQuick Open (File Picker)workbench.action.quickOpen
Control+TabNavigate to next editor in groupworkbench.action.quickOpenNavigateNextInEditorPicker
Shift+Control+TabNavigate to previous editor in groupworkbench.action.quickOpenNavigatePreviousInEditorPicker
Command+PageDownNavigate to next tabworkbench.action.nextEditor
Command+PageUpNavigate to previous tabworkbench.action.previousEditor
Command+= / Control+=Zoom Inworkbench.action.zoomIn
Command+- / Control+-Zoom Outworkbench.action.zoomOut
Command+0 / Control+0Zoom Resetworkbench.action.zoomReset

Basic Editing

Default Key BindingDescriptionCommand
Control+V / Command+VPaste from clipboardeditor.action.clipboardPasteAction
Control+S / Command+SSave fileworkbench.action.files.save

Language Features

Default Key BindingDescriptionCommand
F2Renameeditor.action.rename
F12 or gdGo-to Definitioneditor.action.revealDefinition
Shift+F12Go-to Referenceseditor.action.goToReferences

List / Menu commands

NOTE: Some of the list select commands may not be fully hooked up yet, such that they may not respect vertical/horizontal opening.

Default Key BindingDescriptionCommand
Up Arrow / Control+PMove focus uplist.focusUp
Down Arrow / Control+NMove focus downlist.focusDown
EnterSelect current itemlist.select
Shift-EnterSelect current item (vertical open)oni.list.selectVertical
Ctrl-xSelect current item (horizontal open)oni.list.selectHorizontal
Ctrl-tSelect current item (new tab)oni.list.selectNewTab

Search Pane

Default Key BindingDescriptionCommand
F4Focus next search resultsearch.action.focusNextSearchResult
Shift+F4Focus previous search resultsearch.action.focusPreviousSearchResult

Sidebar

Default Key BindingDescriptionCommand
Command+Shift+E / Control+Shift+EFocus Explorerworkbench.view.explorer
Command+Shift+F / Control+Shift+FFocus Searchworkbench.action.findInFiles
Command+Shift+X / Control+Shift+XFocus Extensionsworkbench.view.extensions
Control+Shift+GFocus Source Controlworkbench.view.scm
Control+W, Control+JNavigate down a sectionvim.window.moveDown
Control+W, Control+KNavigate up a sectionvim.window.moveUp

Snippets

Default Key BindingDescriptionCommand
n/aInsert a Snippeteditor.action.insertSnippet
n/aConfigure user snippetsworkbench.action.openSnippets

Window Management

Default Key BindingDescriptionCommand
Control+W, Control+VVertical Splitview.splitVertical
Control+W, Control+SHorizontal Splitview.splitHorizontal
Control+W, Control+HMove to left splitwindow.moveLeft
Control+W, Control+LMove to right splitwindow.moveRight
Control+W, Control+JMove down a splitwindow.moveDown
Control+W, Control+KMove up a splitwindow.moveUp
Control+W, Control+RRotate forwardsview.rotateForward
Control+W, Control+Shift+RRotate backwardsview.rotateBackward
Decrease editor sizeworkbench.action.decreaseViewSize
Increase editor sizeworkbench.action.increaseViewSize
Control+W, <Decrease editor size horizontallyvim.decreaseHorizontalWindowSize
Control+W, >Increase editor size horizontallyvim.increaseHorizontalWindowSize
Control+W, -Decrease editor size verticallyvim.decreaseVerticalWindowSize
Control+W, +Increase editor size verticallyvim.increaseVerticalWindowSize
Decrease editor size upvim.decreaseWindowSizeUp
Increase editor size upvim.increaseWindowSizeUo
Decrease editor size downvim.decreaseWindowSizeDown
Increase editor size downvim.increaseWindowSizeDown
Decrease editor size leftvim.decreaseWindowSizeLeft
Increase editor size leftvim.increaseWindowSizeLeft
Decrease editor size rightvim.decreaseWindowSizeRight
Increase editor size rightvim.increaseWindowSizeRight
Control+W, OMaximize editorworkbench.action.maximizeEditor
~~Control+W, \~~Maximize editor horizontallyvim.maximizeWindowWidth
Control+W, _Maximize editor verticallyvim.maximizeWindowHeight
Toggle editor group sizesworkbench.action.toggleEditorWidths
Control+W, =Reset editor sizesworkbench.action.evenEditorWidths

Vim commands

Default Key BindingDescriptionCommand
EscapeUsed to send <ESC> to Vimvim.esc

Additional Commands

Default Key BindingDescriptionCommand
n/aEnable KeyDisplayerkeyDisplayer.enable
n/aDisable KeyDisplayerkeyDisplayer.disable

Ex Commands

Commands that start with a : (colon) will be interpreted as vim ex commands. These can also carry arguments.

Examples:

  {"key": "kk", "command": ":split", "when": "editorTextFocus"},
  {"key": "<C-D>", "command": ":d 2", "when": "insertMode"}

Leader Key

A leader key can be specified via the following configuration setting:

{ "vim.leader": "<space>" }

NOTE: This setting is in configuration.json, not keybindings.json

Alternatively, the leader key can be specified via an Ex command:

:nmap <space> <Leader>

Once the leader key is defined, it may be used in both keybindings.json and via VimL map commands:

[
  { "key": "<Leader>p", "command": "workbench.action.quickOpen", "when": "editorTextFocus && normalMode" }
]

or, alternatively, in VimL:

:nnoremap <Leader>p <C-S-P>
← SettingsExtensions →
  • Editing the keybindings
    • Keybinding Format
    • key format
    • Remaps
    • Key Sequences
    • command arguments
    • when clause contexts
  • Commands
    • Basic Editing
    • Language Features
    • List / Menu commands
    • Search Pane
    • Sidebar
    • Snippets
    • Window Management
    • Vim commands
    • Additional Commands
    • Ex Commands
    • Leader Key
Onivim 2 User Manual
Docs
Getting StartedBasic UsageFor DevelopersFAQ
Community
RedditDiscordTwitter
More
GitHubStar
Copyright © 2022 Outrun Labs, LLC