Working with ^h and ^m in the redirect file in Vim

Source: Internet
Author: User

When doing the experiment, the log redirection is written to the file for easy viewing later. But with vim opened after a lot of ^h and ^m, like garbled. :

Now try to solve this problem in vim.

  • Replace ^h
    Enter a command in vim to replace the ^h with a space (note//with a space between)
    :%s/^H/ /g
    Explain:
    s: Represents a Replace operation
    %: "%": indicates the entire file. The symbol in front of s indicates the scope of the search, and the current line is omitted. such as: "1,20": means from line 1th to 20;
    /: delimiter, separating the source and target characters that need to be replaced, and the command
    ^H: Need to replace the content, this is a control character. ^h Input Method: Hold down the CTRL key first, then click the Letter V and the character H to complete the input

  • Replace ^m
    :%s/^M/\r/g
    ^M: is a carriage return line break in a DOS system
    \r: \ is an escape character, \ r denotes a line break under Linux
    Similarly, the input method of ^m: Hold down the CTRL key first, then click the Letter V and the character M

Working with ^h and ^m in the redirect file in Vim

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.