Author: Paco Esteban <firstname.lastname@example.org>
Date: Fri, 6 Dec 2019 17:47:45 +0100
article about vim registers
3 files changed, 143 insertions(+), 0 deletions(-)
diff --git a/src/gophermap b/src/gophermap
@@ -12,6 +12,7 @@ Sometimes I write things so I do not forget ...
o--o-- Random (usually tech) stuff
+0Notes on Vim register /vim-registers.md.txt onna.be 70
0Encrypt a USB flash drive on OpenBSD. /openbsd-encrypt-usb-flash-drive.md.txt onna.be 70
0Long Wireless links and monitoring. /long-wireless-links-and-monitoring.md.txt onna.be 70
0Trying to avoid browser dependency. /browser-dependency.md.txt onna.be 70
diff --git a/src/index.html b/src/index.html
@@ -1,4 +1,5 @@
+<li><a href="/vim-registers.html" title="2019-12-06">Notes on Vim registers</a></li>
<li><a href="/openbsd-encrypt-usb-flash-drive.html" title="2019-08-24">Encrypt a USB flash drive on OpenBSD.</a></li>
<li><a href="/long-wireless-links-and-monitoring.html" title="2019-05-31">Long Wireless links and monitoring</a></li>
<li><a href="/browser-dependency.html" title="2019-05-07">Trying to avoid browser dependency.</a></li>
diff --git a/src/vim-registers.md b/src/vim-registers.md
@@ -0,0 +1,141 @@
+# Vim registers
+Go to the end to see the [summary](#Summary)
+## Introducing Vim registers
+Vim documentation says:
+There are ten types of registers:
+1. The unnamed register ""
+2. 10 numbered registers "0 to "9
+3. The small delete register "-
+4. 26 named registers "a to "z or "A to "Z
+5. Three read-only registers ":, "., "%
+6. Alternate buffer register "#
+7. The expression register "=
+8. The selection registers "* and "+
+9. The black hole register "_
+10. Last search pattern register "/
+It may seem a lot, (and indeed the documentation for registers in Vim is a bit
+complicated for my taste) and one may not use them all (at least not all the
+time), but I'll try to describe them here in simple words. Of course I'll
+leave a lot of functionality and corner cases out of this description. For
+that, `:help registers`.
+Remember that to interact with them you usually use `"` plus the name of the
+register (ex: `"ad` deletes to register `"a`). On Vim scripts, you can refer
+to them (for read and write if allowed) with `@` (ex: `:let @a = "foo"`)
+You can see the contents of all the registers with `:registers`
+## The unnamed register
+This is the one you're already using all the time, for deleting and yanking.
+Everything goes here, no matter what it is, all the time (more or less, check
+docs for details). That's why you get frustrated when you copy something and
+then delete a character and override your copied text.
+This is the register that is invoked if you do not specify a register.
+So things like `d`, `c`, `x`, `dd`, `y` go into here, and things like `p` get
+content from here.
+## The numbered registers
+Those are of 2 types really:
+* `"0` Any yank command goes here (and to `""` too) unless you specify another
+* `"1` to `"9` Any delete or change command goes here unless you specify
+ another register or the change is "small" (less than one line). This works
+ like a queue, when you delete again, goes to `"1` and what was in `"1` goes
+ to `"2`, what was on `"2` to `"3` ... until what was on `"9` gets
+ discarded. So you have some sort of "delete history"
+## The small delete register
+Here go all the delete operations less than one line long unless other register
+## Named registers
+They are not automatically populated. You can use them explicitly to have 26
+"clipboards" if you like. Keep in mind that they are shared with the macros.
+When addressed upper-case, they append the content to the register instead of
+Useful for reorganizing blocs too, you just append blocs of text to one
+register in the order you want and then paste it in the place you want it to
+## Read-only registers
+* `".` Last inserted text. Just like the "dot" command.
+* `"%` Name of the current file.
+* `"` Most recent command line.
+## Alternate file register
+Contains the name of the alternate file (`CTRL-^`), the one marked `#` on `:ls`
+## Expression register
+This is not a register like the others. It allows you to execute an expression
+that is converted to a string and put in place with `p` or automatically if you
+are in insert mode and invoke it with `CTRL-R`.
+## Selection registers
+Those are your system clipboards. Vim has to be compiled with support for
+this. One is the primary and the other is the clipboard ([X11 stuff], you
+know). I never remember which is which, so I have some aliases like this:
+" copy and paste from system easily
+ nnoremap cp "*p
+ xnoremap cy "*y
+ nnoremap cp "+p
+ xnoremap cy "+y
+## Black hole register
+This is like sending stuff to `/dev/null`
+## The last search pattern register
+Contains the most recent search pattern. Not sure of its utility, but it's
+* If you do not specify a register, `""` (the unnamed register) is used.
+* Your last copy is always available at `"0`.
+* A "delete history" is available on `"1` to `"9`.
+* Less than one line deletions are available on `"-`
+* There are 26 "clipboards" in Vim (`"a` to `"z`) that can be appended
+ addressing them upper-case.
+* You can evaluate expressions (like basic arithmetic and more) with the
+ expression register `"=`
+* Interacting to and from the system clipboard is possible with the selection
+* If you have something sensible that want to delete, use the black hole
+ register `"_`
+* You can check the contents of all the registers with `:registers`
+Hope it helps, and I hope I do not forget now.
+_Have any comments ? Send an email to the [comments address]._