Onivim 2 User Manual

Onivim 2 User Manual

  • Early Access
  • About
  • Timeline
  • Docs

›Basic Usage

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

Snippets in Onivim 2

Snippets are text templates that simplify entering blocks of source code. Snippets are especially useful for code blocks that are repeated frequently with minor variations.

snippet-demo

In insert mode, as you type, Onivim shows available snippets alongside completion items.

The snippet syntax follows the Code Snippet Syntax (which is a subset of the TextMate Snippet Syntax). In addition, Onivim supports many of the same snippet configuration options as Visual Studio code, such as "editor.snippetSuggestions".

Using snippets

When a snippet is selected in the completion pop-up, pressing Tab will expand the snippet.

While a snippet is active, the mode will show as Snippet in the bottom-right, on the status bar. Pressing Tab while a snippet is active will move the cursor to the next placeholder, while pressing Shift+Tab will move the cursor to the previous placeholder.

Once the cursor has been moved to the final placeholder, snippet mode will deactivate, and the editor will be returned to insert mode..

Installing snippets

Onivim 2 comes bundled with snippets for several languages, including JavaScript, TypeScript, Reason, and others.

Extensions from open-vsx can be installed to provide additional snippets:

snippet-installation

You can explore extensions that provide snippets by using the @category:"snippets" search filter in the extensions pane.

Snippet syntax

Onivim's snippet syntax follows the same snippet syntax as Code, including:

  • Tabstops: $1, $2, ... $n designate cursor positions within the snippet. $0 is a special tabstop, designating the final cursor position. If there are multiple instances of the same tabstop, they will be synchronized and updated together.

  • Placeholders: Default values can be specified for tabstops, like ${1:default}.

  • Variables: $name specifies a variable that can be inserted, such as $CURRENT_YEAR.

Customizing snippets

user-snippets

Snippets may be customized globally or per-filetype - these are stored in the user snippets folder:

  • If the snippet file ends with extension .json, the filename is the relevant filetype - for example, bat.json provides snippets for the bat filetype.
  • If the snippet file ends with extension .code-snippets, the snippets file applies globally, to all filetypes.

To configure your snippets:

  • Open the command palette (Control+Shift+P / Command+Shift+P)
  • Select "Configure user snippets"
  • Choose the filetype to modify
  • Press Enter to open the relevant snippet file
  • Modify and save

Binding a snippet to a key

Snippets can also be bound to keys, using the "editor.action.insertSnippet" command, for example:

snippet-key-binding

← EmmetSettings →
  • Using snippets
  • Installing snippets
  • Snippet syntax
  • Customizing snippets
  • Binding a snippet to a key
Onivim 2 User Manual
Docs
Getting StartedBasic UsageFor DevelopersFAQ
Community
RedditDiscordTwitter
More
GitHubStar
Copyright © 2022 Outrun Labs, LLC