Vim Replacement Lookup

Source: Internet
Author: User

# #一, substitution and revocation of characters (undo action)
# # #1. Replace and revoke (undo) commands
Both the Replace and undo commands are for normal mode operations
Command | Description
-----|-----
' R ' +< letters to be replaced > | Replace the letter that contains the cursor with the specified letter
' R ' | Continuous replacement until ' ESC ' is pressed
' 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
' C ' (uppercase) | Replace cursor to end of line
`~` | Reverses the case of a cursor in the same letter
' U ' {n} | Undo One or N operations
' U ' (uppercase) | Undo all changes to the current line
' Ctrl+r ' | Redo, that is, undo undo operation
To open a file for editing:
```
$ vim practice_2
# Enter the following text
Www.shiyanlou.com
```
Then do the following:
-Enter ' 11G ' and jump to line 11
-Enter FA to jump to the first ' a ' character
-Enter ' r ', and input b,a character is replaced by B character (practical)
-Enter ' R ' to replace character, enter new string, press ESC to return to normal mode (practical)
-Enter ' CC ' to replace whole line characters, enter new string, press ESC to return to normal mode after entering
-Enter ' CW ' to replace an English text (word), press ESC to return to normal mode (useful)
-Enter ' ~ ' to flip the case of the character where the cursor is located
-Input ' C ' is replaced with the end of the line, that is, the word will be replaced when the cursor is in place, press ESC to return to normal mode after entering
-Enter ' U ' to undo last operation
! [] (Https://dn-anything-about-doc.qbox.me/md041718vim5+.gif)
# #二, 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
```
-Input ' 15G ' in normal mode, jump to 15 lines
-Input ' >> ' line is indented to the right in normal mode (used to format code super cool)
-In normal mode, enter ' the whole line to the left to rewind
-Normal mode input ': ' Enter command line mode to set the ' Shiftwidth ' value to control the number of characters for indentation and fallback
# # #2. shiftwidth command
The ' shiftwidth ' command refers to the indentation generated by the previous section ' >> ' command (can be simply written ' SW ')
Normal mode Enter ': ' Enter command line mode to set the ' Shiftwidth ' value to control the number of characters for indentation and fallback
Get the current set value
: Set shiftwidth?
```
Set indent to 10 characters
: Set shiftwidth=10
```
Enter ' ESC ' back into normal mode and try ' >> ' again to see if the indent is changing
# # #3. Adjust text position
Command line mode enter ': CE ' (center) command to center the contents of the bank
```
: CE
```
command-line mode, enter ': ri ' command to make our text on the right
```
: RI
```
Command line mode, enter: ' Le ' (left) command to leave the contents of the bank
```
: le
```
! [] (Https://dn-anything-about-doc.qbox.me/md041718vim6+.gif)
# #三, find
# # #1. Quick Find
Enter '/' in normal mode and then type the string you want to find and press ENTER to find it.
'? ' and '/' function the same, just '? ' is up and '/' is looking down.
After entering the search, enter ' n ' and ' n ' to continue to find
' n ' means continue lookup, ' n ' reverse lookup
# # #2. Quick Find Exercises
Use VIM to open a file for editing
```
$ VIM Protocols
```
-Enter '/icmp ' in normal mode to find the string ICMP
-Enter ' n ' in normal mode to find the next ICMP
-Input in normal mode '? TCP ' Looks up string TCP
-Enter ' N ' in normal mode to find the previous TCP
# # #3. Advanced Find
-Enter ' \* ' in normal mode to find the word where the cursor is located
-Normal mode input ' \# ' ibid, but ' \* ' is forward (up) to find, \ #则是向后 (next) find
-Enter ' g\* ' with ' \* ' in normal mode, but partially conform to the word
-Enter ' g\# ' with ' \# ' in normal mode, but partially conform to the word
Search for ' n ' above, ' n ' Continue search command is still available
# # IV, Summary
This section learns about substitutions, undo operations, and Quick Find, where replacement and quick find within a document is useful, and you want to be able to master

Vim Replacement Lookup

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.