Skip to content

1. Cursor mode vs Extend mode

mg979 edited this page Aug 31, 2019 · 7 revisions

Imgur

The most basic concept behind VM is the region: each cursor/selection is a region. Each region is defined by a starting byte offset and an ending byte offset. For cursors, the starting and ending point are the same, and while this can be true for selections too, cursors behave like regions with 0 width.

The difference between cursors and selections is roughly the same between normal and visual mode. They are highlighted differently, so that you always know in which mode you're in.

In cursor mode, you can expect most normal mode commands to work in the same way: change/delete/yank require a motion, you can paste before or after the cursor, you can use a, A, i, I to enter insert mode, and commands like 'x', 'X', '~', 'r', work as usual.

In extend mode, many commands behave as they would in visual mode. You're not really in visual mode: everything happens in normal mode. But some commands (c, d, p) behave as they would in visual mode, while others (i, I, a, A, ...) work normally.

At any time you can switch between cursor/extend mode with the Tab key. Switching from extend mode will collapse the selections to their initial offset.

In extend mode, pressing o will invert facing, as in vim visual mode. If you press Tab after having pressed o, selections will be collapsed, but the cursors will be positioned at the end of the selection.

Maps:

  • Tab: switch between cursor/extend mode.
  • motions: move cursors (cursor mode) or extend selection (extend mode)