Linux VI replacement string __linux

Source: Internet
Author: User

1. Introduction

When using VI, something needs to replace the string

The basic substitution
: s/vivian/sky/replaces current line first Vivian for Sky
: S/vivian/sky/g replaces current line all Vivian for Sky
: N, $s/vivian/sky/replaces the first n line to the top Vivian for each line in the last line of Sky
: N, $s/vivian/sky/g replaces the first n line to each line in the last line all Vivian for Sky
(n is a number, if N is., which means starting from the current line to the last line)
:%s/vivian/sky/(equivalent to: g/vivian/s//sky/) replaces the first Vivian of each line as Sky
:%s/vivian/sky/g (equivalent to: g/vivian/s//sky/g) replaces all Vivian in each row as Sky

2. Use #或 + as separator

You can use the #或 + as the separator, which appears in the middle/not as a separator
: s#vivian/#sky/# Replace the first vivian/of the current line as sky/
:%s+/oradata/apras/+/user01/apras1+ (using + to replace/):/oradata/apras/replaced with/user01/apras1/


Section excerpt from http://blog.csdn.net/aldenphy/article/details/4019486

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.