Basics: registers?

This commit is contained in:
Marco Hinz 2016-01-06 16:57:59 +01:00
parent bf5a67569a
commit f69d48da79
2 changed files with 28 additions and 0 deletions

View File

@ -6,6 +6,7 @@ All notable changes to this project will be documented in this file.
### Added ### Added
- Basics: [Quickfix and location lists?](README.md#quickfix-and-location-lists) - Basics: [Quickfix and location lists?](README.md#quickfix-and-location-lists)
- Basics: [Registers?](README.md#registers)
- Basics: [Autocmds?](README.md#autocmds) - Basics: [Autocmds?](README.md#autocmds)
- Quirks: [Newline used for NUL](README.md#newline-used-for-nul) - Quirks: [Newline used for NUL](README.md#newline-used-for-nul)
- Quirks: [Bracketed paste (or why do I have to set 'paste' all the time?)](README.md#bracketed-paste-or-why-do-i-have-to-set-paste-all-the-time) - Quirks: [Bracketed paste (or why do I have to set 'paste' all the time?)](README.md#bracketed-paste-or-why-do-i-have-to-set-paste-all-the-time)

View File

@ -13,6 +13,7 @@ added every day. Things about to be added can be found here:
- [Active, loaded, listed, named buffers?](#active-loaded-listed-named-buffers) - [Active, loaded, listed, named buffers?](#active-loaded-listed-named-buffers)
- [Mappings?](#mappings) - [Mappings?](#mappings)
- [Mapleader?](#mapleader) - [Mapleader?](#mapleader)
- [Registers?](#registers)
- [Autocmds?](#autocmds) - [Autocmds?](#autocmds)
- [Quickfix and location lists?](#quickfix-and-location-lists) - [Quickfix and location lists?](#quickfix-and-location-lists)
- [Colorschemes?](#colorschemes) - [Colorschemes?](#colorschemes)
@ -191,6 +192,32 @@ the local mapleader.
See `:h mapleader` and `:h maplocalleader` for more. See `:h mapleader` and `:h maplocalleader` for more.
#### Registers?
Registers are slots that save text. Copying text into a register is called
**yanking** and extracing text from a register is called **pasting**.
Vim provides 10 types of registers:
| Type | Character | Filled | Contains text from.. |
|------|-----------|--------|----------------------|
| Unnamed | `"` | implicitely | Last yank or deletion. (`d`, `c`, `s`, `x`, `y`) |
| Numbered | `0` to `9` | implicitly | Register `0`: Last yank. Registers `1`: Last deletion. Register `2`: Second last deletion. And so on. Think of registers `1`-`9` as a read-only [queue](https://en.wikipedia.org/wiki/Queue_(abstract_data_type)) with 9 elements. |
| Small delete | `-` | implicitely | Last deletion that was less than one line. |
| Named | `a` to `z`, `A` to `Z` | explicitely | For your own use. If you yank to register `a`, you replace its text. If you yank to register `A`, you append to the text in register `a`. |
| Read-only | `:`, `.`, `%` | implicitely | Register `:`: Last command. Register `.`: Last inserted text. Register `%`: Current filename. |
| Alternate buffer | `#` | implicitely | Most of the time the previously visited buffer of the current window. See `:h alternate-file` |
| Expression | `=` | explicitely | Evaluation of the VimL expression that was yanked. E.g. do this in insert mode: `<c-r>=5+5<cr>` and "10" will be inserted in the buffer. |
| Selection and Drop | `+`, `*`, `~` | implicitely | `*` and `+` are the [clipboard](#clipboard) registers. Register `~`: From last drag'n'drop. |
| Black hole | `_` | explicitely | Use this register if you don't want any other registers implicitely affected. E.g. `"_dd` deletes the current line without affecting registers `"`, `1`, `+`, `*`. |
| Last search pattern | `/` | implicitely | Last pattern used with `/`, `?`, `:global`, etc. |
There are numerous exceptions when registers get implicitely filled, so be sure
to read `:h registers`.
**Fun fact**: In Emacs "yanking" stands for pasting (or _reinserting previously
killed text_) not copying.
#### Autocmds? #### Autocmds?
On many occasions, Vim emits events. You hook into these events by using On many occasions, Vim emits events. You hook into these events by using