Skip to content

Registers

mg979 edited this page Apr 11, 2019 · 3 revisions

Yank, Delete, Paste

Deleting and yanking work in cursor/extend mode as they would in normal/visual mode, that is, expecting a motion or not.

Pasting follows some special rules:

  • if no regions have been yanked in VM, and there's no set VM register, all regions are replaced by the contents of the default/chosen vim register.

  • if multiple regions have been yanked in VM, VM will paste as many regions it can:

    • if the current number of regions/cursors is higher than the yanked regions, some regions will be left unaltered

    • if it's lower, some yanked text won't be pasted


Find all

Imgur Imgur

You can select all occurrences of a given text by pressing leader-A

  • if pressed in normal mode with no region under the cursor, it will select all occurrences of the word under it, and only whole word matches will be accepted.

  • if pressed in visual mode, it will select the escaped pattern of the visually selected text.

  • if pressed while a selection is under the cursor, it will re-use the pattern of the selection: if this pattern is a regex (because the region has been selected through a regex search), all occurrences of that pattern will be selected.


Using registers

VM has its own set of specific registers, stored in the g:Vm.registers global variable. This variable holds a dictionary, where each key is a register, and the values are lists of text, one for each yanked region.

VM registers persist after VM has been exited, except the unnamed register. You can also make them persistent across sessions:

let g:VM_persistent_registers = 1

Normally, when you paste something, VM registers are used, unless empty. In that case, the vim register is used instead. When yanking/deleting, VM registers are used, and vim registers are not overwritten. You can let VM overwrite vim registers by default (this was the default behaviour until a while ago):

let g:VM_overwrite_vim_registers = 1

If yanking/deleting more regions, text is converted to a specific type before being saved to a vim register:

single region v
multiline V
multiple regions block

You can force access to/from vim registers, bypassing VM registers:

leader-y yank to vim register (only in extend mode)
leader-p p paste from vim register (also in extend mode)
leader-P P paste from vim register

Finally, the unnamed register is always overwritten and never saved across VM instances or across sessions.

Clone this wiki locally