Use Vim to process case-insensitive conversion of Characters

Source: Internet
Author: User
Tags ranges

Address: http://blog.csdn.net/ruixj/article/details/3765385

WriteProgramOften encounter case-insensitive conversion problems,VimIt provides many easy case-sensitive conversion commands, which can be used in combination with vim's cursor movement commands to quickly convert uppercase and lowercase letters, words, and any rows.

 
~ Change the uppercase and lowercase letters under the cursor

3 ~ Change the case sensitivity of the three letters starting from the cursor position

G ~~ Change the case sensitivity of the current row

U converts all selected letters in visual mode to uppercase letters

U converts all selected letters in visual mode to lowercase letters.

Guu converts the letters of the current row into uppercase letters.

3guu: replace the three lines from the cursor to the following with uppercase letters.

Guu converts all letters in the current row to lowercase letters.

Guw converts words under the cursor to uppercase.

Guw changes the words under the cursor to lowercase.

In vim, the upper and lower case conversion commands are:
Gu or gu
One point in the image is that the small U means to be converted to lower case; the large U means to be converted to upper case.

The rest is the limitation of the two commands (limited operation rows, letters, words) and so on.

1. EntireArticleConvert uppercase to lowercase
After opening the file, you do not need to enter the command line mode. Type: gggug

Explanation: gggug is divided into three parts: Gg Gu g
Gg = cursor to the first character of the file
Gu = lowercase all selected ranges
G = end of File

2. The entire article is converted to uppercase in lowercase.
After opening the file, you do not need to enter the command line mode. Type: gggug

Explanation: gggug is divided into three parts: Gg Gu g
Gg = cursor to the first character of the file
Gu = uppercase all selected ranges
G = end of File

3. Only convert a word

Guw and jiue
Guw and jiue
In this way, the words behind the cursor are converted to uppercase and lowercase letters.
The command to convert five words is as follows:
Gu5w, gu5e
Gu5w, gu5e

4. Convert the case sensitivity of several rows.

Position the cursor on the row to be converted, and type: 1gu to perform small-to-UPPERCASE conversion from the row where the cursor is located to the next row.
10 Gu, then the 11 rows are converted to uppercase
And so on, there are other case-insensitive conversion commands.
Gu0: changes from the cursor position to the beginning of the line to uppercase
Gu $: changes from the cursor position to the end of the line to uppercase
Gug: changes from the cursor position to the last character in the article to uppercase.
Gu1g: changes from the cursor position to the first character in the document to uppercase.

End

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.