RHCE7 the use of the Learning Note 4--vim Editor

Source: Internet
Author: User

1. gedit Graphic Editing file


2, vim operation of a file, if the file exists is opened, if the file does not exist, it will be created:

[[email protected] ~]# vim XX

3. Three modes of VIM:

(1) command line mode;

(2) Insert mode:

(3) the last line mode;

When using Vim to open an edit file, the default is the command line mode:

4. When editing a file, go to insert mode from the command line and press the following key to enter:

  • I, enter from the current cursor;

  • A, enter from the next character of the current cursor;

  • O, insert the next line in the current row;

  • I, jumping from the current cursor to the beginning of the bank and entering;

  • A, jump to the end of the bank and enter;

  • O, insert one line on the previous line of the bank;

  • R, replacing the current character;

  • R, replacing the current character and jumping to the next character;

  • Number+g: Jumps to the specified line, such as 10G jumps to the 10th row, GG jumps to the last row, GG jumps to the first line;

  • Number+yy: Copy the number of rows down the current line, press p on any line to paste;

  • NUMBER+DD: Cuts the number of rows down the current line, pressing p on any line;

  • U: Undo the previous operation;

  • Ctrl+r: Restore the previous operation;

  • Ctrl + V: Enter the visual block mode, move up and down through the cursor, select the contents, press Y to copy the selection, press paste at any location;

  • Quickly add comment # at the beginning of the line, move the cursor to the beginning of the line, then press I to start position, press #, press ESC to exit

#abrt: X:173:173::/etc/abrt:/sbin/nologin#pulse:x:171:171:pulseaudio System daemon:/var/run/pulse:/sbin/nologin# Gdm:x:42:42::/var/lib/gdm:/sbin/nologin#gnome-initial-setup:x:993:991::/run/gnome-initial-setup/:/sbin/nologin
    • : Split: Enter split-screen mode, Ctrl+w W can switch between the upper and lower screen;


To see the detailed help for VIM, you can enter Vimtutor.

650) this.width=650; "src="/e/u261/themes/default/images/spacer.gif "style=" Background:url ("/e/u261/lang/zh-cn/ Images/localimage.png ") no-repeat center;border:1px solid #ddd;" alt= "Spacer.gif"/>

5, the last row of the file to save, find, property settings, replacement and other operations


  • Enter the last line mode, ESC from INSERT INTO command mode, enter: (or/, commonly used to find, n search from top to bottom, N to look up from below)

  • Save: Wq Save and exit, or X;

  • Forced exit: q! Does not save the file modification content;

  • Display line number: Set Nu, if the default display line number, you need to modify the home directory under the VIMRC file or/ETC/VIMRC, do not create a file, insert a row set Nu;

  • Toggle the specified line: Enter the line number directly;

  • Replace: 1, $s/old/new/g replace global all

  • M,ns/old/new/g replaces all matches of m rows to n rows,. Represents the current line, $ represents the last row, $-1 represents the penultimate row, and (1,$) can also use% substitution, which is the full text. If there are special characters in the content to match, such as/,*, you need to add the escape character in front \

  • You can use s#old#new# with the # delimiter, and the special characters do not need to be escaped;

  • Look below the backslash, and if you want to ignore the case, add \c after the lookup, for example:/servername\c


This article is from the "Ordinary Road" blog, please be sure to keep this source http://linjohn.blog.51cto.com/1026193/1598075

RHCE7 the use of the Learning Note 4--vim Editor

Related Article

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.