command lab
  • TOP
  • vim

  • [Vim practice] TIPS that you can learn by touching transcendental convenient registers

[Vim practice] TIPS that you can learn by touching transcendental convenient registers

The register is a feature that I definitely want to learn if I mainly use vim.

Since vim has the property that the contents are saved in the register each time you perform yanking or erasing, you may not be able to copy and paste as well as a normal editor. Especially when you delete, the contents are saved one by one, so people who are accustomed to ordinary editors will not be able to paste the contents as they want, and will stumble.

If you are familiar with the properties and functions of registers and become familiar with its operation, you will be comfortable using vim as your main editor.

First, actually practice

Press the START button below to enter practice mode.
STARTSTOP
* Input mode switching ctrl + shift + alt + space
PRE
NEXT
Guide mode
Repeat mode
PUSH ENTER

Register operation basics

The basic operation of register operation is to start register operation with “”, then specify register name such as “a”, and copy (yank) or cut operation such as “y” and “d”. It becomes the flow of doing. In the above exercise, the paste is performed immediately after copying, but if you save the register with a name such as “a”, even if you perform various operations in between, unless you overwrite the register of “a”, You can paste the “a” value at any time.

Basic form “””→”a to z characters”→”commands such as y”

Register-related command

Introducing commands that are likely to be used based on the above basics. The register names are specifically introduced below, but please think that anything is possible between the basic “a~z”.

Save selection in register “a” “ay
Save current line to register’b’ “byy
Erase selected range and save to register “c”“cd
Erase current line and save to register “d” “ddd
Paste the contents of register “a” “ap

Display register information list

This command is input when you want to check the contents of the saved register. By the way, the “0” of the register contains the most recently copied (yank) , and the “1~9” stores the deleted history in order. .. This is listed below.

Display register information list :reg enter

Register names

As you can see from the register list, registers are registered under various names. For each meaning, we will focus on the parts that are frequently used.

Register “0” Stores the latest yanked information. Conversely, the contents operated by “d” and “x” are not saved.
Register “1 to 9” The information deleted most recently is stored in order. Information after 9 will be deleted.
Register “az” The name of “az” can be explicitly specified and saved. When saving a register this way, it is not stored in register 0.

About using registers in INSERT mode

When using a register in INSERT mode, press “ctrl + r” followed by “register name”. If you press “ctrl + r”, the cursor will change to “”, so if you enter a register registration name such as “a~z” in that state, the contents will be pasted.

Register paste in INSERT modectrl + r [register name]

Finally

Actually, there are still other register commands, but I will omit them because they may be confusing if you introduce them all. However, if you keep in mind what I have introduced here, I think that you will be able to use vim as a main editor enough, so please practice and acquire it.

コメントを残す

CAPTCHA


The comment will be displayed after approval by the site administrator. Please follow the manners and comment.