How to replace selected lines or specify text within several lines in vim
曾经蜡笔没有小新
曾经蜡笔没有小新 2017-05-16 16:39:59
0
2
669

Checked the vim command list on the Internet, only the command to replace the current line with full text or replace with full text

曾经蜡笔没有小新
曾经蜡笔没有小新

reply all(2)
PHPzhong
:'<,'>s/替换项/替换为/g

The following command replaces all strings idiots with managers in this article:

:1,$s/idiots/manages/g

Usually we use % in the command to refer to the entire file as the replacement range:

:%s/search/replace/g

The following command specifies replacement only between lines 5 to 15:

:5,15s/dog/cat/g

The following command specifies replacement only between the current line and the end of the file:

:.,$s/dog/cat/g

The following command specifies replacement only within the next 9 lines:

:.,.+8s/dog/cat/g

You can also use specific characters as the replacement range. For example, replace all equal signs (=) in the SQL statement from FROM to the semicolon with inequality signs (<>):

:/FROM/,/;/s/=/<>/g

In visual mode, first select the replacement range, and then enter: to enter command mode, you can use the s command to replace text in the selected range.
- VIM study notes Substitute (may require Anti-GFW)

大家讲道理

Control+v enters visual block mode, press hjkl to select the content to be operated, d means cut, p means paste

Oh, maybe I misunderstood the question. .

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template