Back to Oh My Posh

Vi mode

website/docs/segments/system/vimode.mdx

29.21.02.1 KB
Original Source

What

Display the current Vi mode (insert / normal / visual …) in the prompt. Useful when using ZSH keymaps via bindkey -v or PowerShell PSReadLine -EditMode Vi so you can tell at a glance which mode you are in.

In ZSH, adding this segment automatically registers a zle-keymap-select hook. In PowerShell, it registers a PSReadLine Vi mode change handler. Both re-render the prompt every time the active mode changes.

:::caution PowerShell cursor indicator

PowerShell support sets PSReadLine's ViModeIndicator to Script, replacing cursor-shape mode indicators such as Cursor. The mode is then shown by this segment in the prompt instead.

:::

Sample Configuration

import Config from "@site/src/components/Config.js";

<Config data={{ type: "vimode", style: "plain", foreground: "#ffffff", background: "#0077c2", template: " {{ if eq .Mode "normal" }} NORMAL{{ else if eq .Mode "visual" }} VISUAL{{ else }} INSERT{{ end }} ", }} />

Template (info)

:::note default template

template
 {{ .Mode }}

:::

Properties

NameTypeDescription
.Modestringthe normalized mode: insert, normal, visual, viopp, replace, or the raw keymap when unmapped
.Keymapstringthe raw mode value ($KEYMAP in ZSH, e.g. main, viins, vicmd, visual, viopp; viins or vicmd in PowerShell PSReadLine)