Shell Note Finishing 1---Vim compiler basic application (refer to Brother Bird)

Source: Internet
Author: User

1. The configuration files in Linux exist in the form of plain ASCII text

2, vim text compiler.

    • General mode: A file opened with VI directly into the general mode, this mode can move the cursor and delete characters, copy and paste, etc., but can not be compared to the text content.

More important operations in general mode:

X: Remove one character backwards.

X: Deletes a character forward.

NX: Removes n characters backwards, as in the same x.

DD: Deletes the entire row where the cursor is located, and can also use NDD to delete n rows.

D1G: Removes all data that the cursor sits on to the first line.

DG: Removes all data from the cursor to the last line.

YY: The line where the cursor is copied. You can also use the NYY command. Y1g,yg.

P: Pastes the next line of the cursor. P Pastes the previous line of the cursor.

U: Restores the previous operation.

Ctrl-r: Repeats the last action.

A,o,i: Inserts into insert mode.

R: Entering replace mode, R replaces the character of the cursor once. R will always replace the text where the cursor is located

    • Edit mode: The INSERT or replace Word appears on the interface is the edit mode, "ESC" exits the edit mode.
    • Command-line mode: In general mode we can enter ":,/,?" A large number of characters can be read and replaced by any of the three buttons. To use the following instructions, first use:

W: Tag data is written to the hard disk.

w!: Forced write, but not necessarily successful.

Q: Leave the VI compiler.

Wq: Save after leaving.

ZZ: If the file is not changed, do not save leave, if the file is changed, then save exit.

W[filename]: Can be understood as save as.

R[filename]: Read in another file. Load to the back of the cursor.

N1,N2 w [filename]: Saves the contents of N1 and N2 as a filename file.

Set num: Displays the line number, which is canceled by the set Nonu.

N1,n2s/word1/word2/g:n1 and N2 represent the number of rows, and N1 and N2 find Word1 replaced by Word2.

1, $s/word1/word2/g: can be understood as the full text, you can also add C for replacement confirmation.

/word: Represents finding Word.

N: Indicates finding the next conforming string.

N: Indicates finding the last matching string.

    • Common operations for VIM:

Filename.swap: If you are disconnected for some reason and your file is not saved, we will use the. swap file, which will give you the cause of the error and the solution, r loads the. Swap content, but swap is not deleted, the swap file should be deleted after saving, D: does not load directly Delete swap files.

Multi-file operation and multi-window functionality.

Block selection: First use Ctirl-v to enter the fast selection (visual block), when the cursor can move up and down but will be white, you can select a column can also be a row, and then press Y to copy, back to normal mode and press p to copy.

. VIMRC and. Viminfo: These two files are stored in a set command related.

Coding problem: Chinese encoding has UTF8, gb2312, BIG5, etc., we want to normal display will use the same encoding. Note the following questions:

The Linux system is encoded in the/etc/sysconfig/i18n file by default.

Terminal Bash is associated with the lang variable.

The encoding of the file itself.

Software encoding.

Workaround: Use Iconv

Iconv command:-F: The original encoding method.

--list: Lists the encodings supported by Iconv.

-t:to is followed by the new encoding method.

-o File: Keep the original file.

Shell Notes 1---Vim compiler basic application (refer to Brother Bird)

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.