Sprout new note-vim command "=", "d", and "y" usage (combined with the cursor movement command, it will be very convenient in some cases), vim is very convenient
Vim has many commands. on the Internet, you can search for a bunch of posts and articles to list commands for various functions.
For "=", "d", and "y", I accidentally discovered some of the same usage. Here are three examples:
= NGdnGynG
N indicates the row number. Note that the row number is followed by the uppercase letter "G ". "NG" is the command to move the cursor to line n.
For "=", "= nG" means formatting from the current row to the nth row. A common command "gg = G" is to execute "gg" to jump the cursor to the first line, and then execute "= G ". If no row number is written, it is the last line. Therefore, "gg = G" Can format all the contents of the current file. The length of the formatted tab is set in. vimrc.
Similarly, dnG is used to cut the current row to the nth row, and ynG is used to copy the current row to the nth row.
In addition, n can be smaller than the current number of rows. For example, if the current row is 70 rows, execute "y35G" to copy the content from 70 rows to 35th rows, in fact, it is equivalent to copying 35 to 70 rows.
With this, it is very convenient in the following scenarios:
Suppose you want to copy the content from 25 rows to 78 rows, then you can directly use "25Gy78G" instead of calculating the total number of rows, and then execute ndd.
For "d" and "y", you can also do this:
"D ^", "d $", cut from the cursor position to the beginning/End of the line, "dw", cut the cursor's current position to the first letter of the word, and so on.
In short, it is to combine "=", "d", and "y" with the operation of moving the cursor to produce the desired effect.