Vim batch replacement, column editing

v im batch replacement:

%s/source_pattern/target_pattern/g

If you want to replace all usernames with login_name, then: %s/username/login_name/g will do.

vim column editor:

  • Column delete ctrl+v, d after selection

  • Insert ctrl+v into the column, shift+i after selection, ESC after editing

  • Column replacement ctrl+v, s after selection, ESC after editing

  • Column copy ctrl+v, y after selection

  • column paste p

1. Column deletion

Operating procedures:

ctrl+v enters the visual operation mode

Use hjkl to control the up, down, left, and right directions to select the part to be deleted

Finally, enter d to delete

2. Batch insert a character Y000000 in the selected column

Operating procedures:

ctrl+v enters the visual operation mode

Use hjkl to control the up, down, left, and right directions to select the position to be inserted

Type an uppercase I (shift+i or CAPSLOCK i) followed by the character you want to type

After inputting, press the ESC key to end, and the currently selected column will insert the entered characters.

  1. Batch replace the selected part with characters 99999

Operating procedures:

ctrl+v enters the visual operation mode

Use hjkl to control the up, down, left, and right directions to select the part to be deleted

Then enter the letter s, and then enter the character to be entered

After inputting, end with the ESC key, and the selected part will be replaced with the entered characters. A replacement operation is a bit like a combination of deletion and insertion.

Guess you like

Origin blog.csdn.net/weixin_43824829/article/details/129728446