(Big Data Engineer Learning Path) Step two vim editor----find and replace

Source: Internet
Author: User

I. Substitution and revocation of characters (undo action) 1. Replace and revoke (undo) command

Both the Replace and undo commands are for normal mode operations

Command Description
r+< to replace letters > Replace the letter that contains the cursor with the specified letter
R Continuous replacement until you press theEsc
cc Replace the entire row, which deletes the row of the cursor and enters insert mode
cw Replace a word, delete a word, and enter insert mode
CUppercase Replace cursor later to end of line
~ Reverses the case of a cursor in the same letter
uN Undo One or N operations
UUppercase Undo all changes to the current line
Ctrl+r Redo, that is, undo undo operation

To open a file for editing:

$ vim practice_2# 输入以下文本www.shiyanlou.com

Then do the following:

    • Input 11G , jump to 11 lines
    • Enter FA to jump to the first a character
    • Input r , and the input b,a character is replaced by the B character (practical)
    • Enter a R replacement character, enter a new string, press ESC to return to normal mode (useful)
    • Enter cc replace whole line character, enter new string, press ESC to return to normal mode after entering
    • Enter cw replace one English word (word), press ESC to return to normal mode (useful)
    • Input ~ , the case of the character in which the rollover cursor is located
    • The input is C replaced with the end of the line, that is, the word will be replaced after the cursor is in place, press ESC to return to normal mode
    • Enter u undo Last action

Second, fast indent 1. Use commands to quickly adjust indent operations

This section learns how to indent quickly in vim and indent operations are effective in normal mode

Open a file for editing

$ vim protocols
    • Normal mode input 15G , jump to 15 lines
    • Input entire line in normal mode >> indent right (used to format code super cool)
    • Enter the entire line in normal mode to the << left fallback
    • Normal mode enter : command line mode to shiftwidth set values to control the number of characters for indentation and fallback
2.shiftwidth command

shiftwidthThe command refers >> to the indentation generated by the previous command (which can be abbreviated sw ). Enter : command line mode to set values in normal mode to control the number of characters in shiftwidth indentation and fallback get current setpoint

:set shiftwidth?

Set indent to 10 characters

:set shiftwidth=10

Enter ESC back into normal mode and try again to >> see if the indent changes

3. Adjust the text position

Command line mode enter :ce (center) command to center the contents of the bank

:ce

Command line mode enter :ri (right) command to make our text

:ri

Command line Mode enter: le (left) command to leave the contents of the bank

:le

Third, find 1. Quick Find

Enter Normal mode / and then type the string you want to find and press ENTER to find it. is the same as the / function, but looks up and / down. After entering the lookup, the input n and N can continue to find n the expression to continue the lookup, N reverse Lookup

2. Quick Find Exercises

Use VIM to open a file for editing

$ vim protocols
    • Normal mode input /icmp find string ICMP
    • Normal mode Enter to n find the next ICMP
    • Normal mode input ?tcp up lookup string TCP
    • Normal mode input N to find the last occurrence of TCP
3. Advanced Search
    • Enter \* a word in normal mode to find where the cursor is located
    • Normal mode input \# Ibid, but \* forward (up) to find, #则是向后 (bottom) find
    • Normal mode g\* \* , but partially matches the word
    • Normal mode g\# \# , but partially matches the word

Search for n The above, N continue to find command can still be used

Iv. Summary

This section learns about substitutions, undo actions, and quick lookups, where replacement and quick find within a document is useful.

(Big Data Engineer Learning Path) Step two vim editor----find and replace

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.