Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
cheat sheet about registers and marks in vim emulators #vs #vim #vsvim #vsc

This was originally written for VsVim, which is a vim emulator for VS. Years later, after also trying a few vim emulators for VSC, I'm convinced that marks and registers are the same among vim emulators for any IDEs and code editors.

Finding opportunities to apply advanced Vim

When it comes to Vim emulators, how to do an advanced operation is not the hard part. The hard part is remembering/recognizing that some routine operation can be helped by Vim.

Log method call

Useful for understanding sloppily/poorly written legacy code. Given a bunch of methods like this:

private void ConfusinglyNamedAndConfusinglyUsedMethod()
  // confusing code here...

Record a macro with a following algorithm: starting at line with name, go to name, yank name, go down, open new line, type logging method, paste name, finish calling logging name, done. Apply this macro to every method with unclear purpose.


private void ConfusinglyNamedAndConfusinglyUsedMethod()
  Debug.Log(nameof(ConfusinglyNamedAndConfusinglyUsedMethod), this);
  // confusing code here...


This file is about marks in Vim emulators.

Most useful

`. — Jump to last change.

` ` — Jump back (in other words, unjump, i.e. navigate back or undo/reverse last jump).

Special registers

'' — Jump back to line (instead of exact position).

Named registers

mm — Place mark m.

'm — Jump to line containing mark m.

`m — Jump to mark m exact position.

Don't forget that all jump operations above, similarly to most (all?) other kinds of jump operations, can be used together with d, c or y.


This file is about registers in Vim emulators.

Most useful

"0 — Last yank. (Very useful when you yanked something, then deleted something in target location, then want to paste yanked text instead of just deleted: "0p.)

"+ — System clipboard.

Special registers

:echo @r — Print register r.

"" — Unnamed register used automatically on dd, yy, etc.

"/ — Last search pattern.

"_ — Black hole. (E.g. "_dd will delete a line without remembering it. Undo will still work as usual though.)

"1 — Big delete (deleted line or lines).

"2"9 — Previous big deletes.

"- — Small delete (deleted text within a single line).

Named registers

"a"z — Named registers.

"rd — Delete into register r.

"ry — Yank into register r.

"Rd, "Ry — Delete or yank appending into register r.


Macros mostly reuse the same register system described above. You can't execute @+ in VsVim though.

qr — Record into register r.

@r — Playback from register r.

@@ — Repeat last playback.

VsVim cookbook

This file is about quirks of VsVim in particular. Ignore it if you're using another Vim emulator.


Filling empty line between { and }

When you type a new method, VS aids you and you end up with this:

private void Foo()


If you don't write anything there immediately, but return to it later, VsVim forces you to type from the hard BoL of the empty line. I don't know any good way to deal with it, but at least there's certainly a nice assortment of acceptable ways:

  • ddO
  • i, End
  • If the expression is simple, just do i and type it (ignoring intendation), it'll auto-format automatically when you type “;” or other trigger.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment