This is the fifth day of my participation in the November Gwen Challenge. Check out the details: The last Gwen Challenge 2021

Cursor movement command

Up and down and left and right

Many people still use up, down, left, and right to move the cursor. In fact, I prefer to use HJKL for cursor movement. Because in vim operation, we usually need to use together with other commands, such as copy and paste, this use we use HJKL will be very convenient.

  • H: Move the cursor left

  • L: Move the cursor right

  • J: Move the cursor down

  • K: Move the cursor up

Other move commands

First let’s look at some basic move commands that can be used in conjunction with other commands, such as add, delete, and so on.

Word, line, head, tail move command

  • Gg: Move cursor to top of document

  • G: Move the cursor to the bottom of the document

  • W: Move the cursor to the beginning of the next word (word);

  • E: Move the cursor to the end of the word.

  • E: Move the cursor to the end of the word (including punctuation);

  • B: Move the cursor to the beginning of the word (begin);

  • B: Move the cursor to the beginning of the word (including punctuation marks);

  • 0: moves the cursor to the beginning of the line.

  • $: Cursor moves to end of line;

Sentence and paragraph movement commands

  • ) : Move to the beginning of the next sentence.

  • (: Move to the beginning of a sentence (test only for English periods.)

  • } : Move to the beginning of the next paragraph (separated by blank lines, both English and Chinese valid)

  • {: move to the beginning of a paragraph (delimited with blank lines, both In English and Chinese)

Combined command

Delete (cut) operation

  • Dd: delete the entire line.

  • D $: deletes from current cursor position to end of line;

  • D0: deletes from the current cursor position to the beginning of the line;

  • Dw: Deletes the beginning of the next word from the current cursor position;

  • De: Deletes from current cursor position to end of word;

  • DE: Deletes from the current cursor position to the end of the word (with punctuation);

  • Db: delete from current cursor position to the beginning of word;

  • DB: delete from the current cursor position to the beginning of the word (with punctuation);

  • DG: delete all rows from current row to last row;

  • DGG: deletes all rows from the current row to the first row.

Supplementary note: sentence and paragraph move with delete command D scenario is not much, not much to introduce here. Run the x command to delete the current character and run the x command to delete the previous character.

Select, copy, and paste commands

Other common commands we use in our daily work include the Select (v), copy (y), and paste (p) commands. Today we’ll take a look at how these commands work in combination with the cursor movement command.

Select the command

  • V $: selects from the current cursor position to the end of the line;

  • V0: from the current cursor position to the beginning of the line;

  • Vw: Select the beginning of the next word from the current cursor position;

  • Ve: Select the end of the word from the current cursor position;

  • VE: From the current cursor position to the end of the word (with punctuation);

  • Vb: Select the beginning of the word from the current cursor position;

  • VB: Select from the current cursor position to the beginning of the word (with punctuation);

  • VG: select all rows from the current row to the last row;

  • VGG: Select all rows from the current row to the first row.

Copy command

  • Y $: copies from the current cursor position to the end of the line;

  • Y0: copies from the current cursor position to the beginning of the line;

  • Yw: Copies the beginning of the next word from the current cursor position;

  • Ye: Copy to end of word from current cursor position;

  • YE: Copy from the current cursor position to the end of the word (with punctuation);

  • Yb: Copies from the current cursor position to the beginning of the word;

  • YB: Copies from the current cursor position to the beginning of the word (with punctuation);

  • YG: copies the current row to the last row.

  • Ygg: copies the current row to all rows in the first row.

Paste command

  • P: Paste after the cursor position

  • P: Paste before the cursor position

Shear command

V Select + d to cut + P to paste

Batch insert operation

With the $character, we can add the same thing to the end of the line in batches. But batch insert data at the beginning of the line using the character ^. The commands for batch insert are as follows.

1. Add the same content at the beginning of the line

:%s/^/ What to addCopy the code

2. Add the same content at the end of each line

:%s/$/ What to addCopy the code

Mobile page

To move the page instead of the cursor, you can use the following command:

  • Control-d: Turn the page Down

  • Control-u: Scroll Up (Up)

  • Control-e: Scroll down one line

  • Control-y: Scroll up one line

Reference documentation

  • Vim Advanced Usage tips

  • Vim internal copy, paste, cut