VI Common Commands

Source: Internet
Author: User

navigating, changing text:

^f ^b/           * forward, scroll back a full screen */
^d ^u/ * forward, scroll back half screen */
Z/ * Move the cursor to the top of the screen and roll the screen */
Z. /* Move the cursor to the middle and roll the screen */
/* Move cursor only */
H/ * Move to line at top of screen */
M/ * Move to middle of screen */
L/ * Move to bottom of screen */
NH/ * Move to the top down nth line */
{}/ * Move forward, move back a section */
[[]]/ * Move to current, beginning of next section */


Search, replace:

N/              * Forward repeat search */
N? / * Back to repeat search */
/pattern/ * Forward search pattern */
? pattern/ * Back to search pattern */

: 1,30s/his/the/g/ * Replaces all of his 1-30 rows with the */
: 1,30S/HIS/THE/GC/ * Confirm Replacement */

Show line number:

:Set nu
: Set Nonu
: 1,10#/ * Displays line number 1-10 */
:. =/ * Displays the current line line number */
: =/ * Displays the total number of files */
:/pattern/=/ * Displays the line number when the pattern first appears */

To delete a row:

: 1,10d/       * Delete 1-10 lines */
:/pattern/d/ * Delete the line containing the pattern */

Open, close, read in, write:

+n      File/* Open files on nth line */
+ File/ * To open files in the last line */
+/pattern File/* Opens the document where the first pattern appears */
-C command File/ * Executes commands after opening the file */

: w/ * Save File */
: X/ * If updated, save file */
ZZ/ * Save and close the file */

: R/home/tim/data/ * reads data into the next line of the cursor */
: $r Data/ * reads data into the end of file */

:., 60w newfile/ * Writes the cursor line to line 60th to NewFile */
: 1,10w >>newfile/ * Append 1-10 lines to NewFile */

Command:

.            /* Repeat last Command */

VI Common Commands

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.