Page History

Vim

Mark George edited this page on 2 May 2023

Clone this wiki locally

Reuse last selection

gv

Jump to last edit

There are a few ways to do this (and I can never remember a single freaking one of them). The best option is to use the changes history:

View the change history:

:changes

The current position is the history is marked by a >

Jump back in the history:

g;

Jump forward:

g,

Multi-select cut/paste

This appends the copied selection into a register, so first clear the register using qaq (for the a register - use qbq for b, etc). This records an empty macro into the register, so you will see messages relating to macros in the status line.

Multi-select yank using :g/<search term>/y A

Multi-select delete using :g/<search term>/d A

Multi-select move using :g/<search term>/m <line to move to>

Also see: https://vim.fandom.com/wiki/Power_of_g

A is the a register, but the uppercase variant causes the command to append to the register. If you didn't append then you will only end up with the last selection in the register.

Paste using "ap where a is the register.

You can view the currently used registers with :registers (shorthand :reg)

Clearing registers

The registers can fill up with crap over time if you have persistence turned on. You can clear out all the registers using the following command:

let regs=split('abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789/-"', '\zs') | for r in regs |  call setreg(r, []) |  endfor | unlet regs

Spell Checking

Turn on spell checking (I usually have it off by default)

set spell
  • Navigate errors with ]s and [s.
  • Show replacements with z=. I also have Telescope configure to do that with <leader>fs.
  • Use :spellrepall to repeat a replacement throughout the document.
  • Add word to temporary ignore list zG
  • Add a word to spellfile zg (permanent ignore).