Subsituting in the entire file

This commit is contained in:
2025-08-20 19:53:38 +03:00
parent 2643062d7a
commit 57042bd21c

View File

@@ -465,3 +465,41 @@ Line mode:
Pressing "<register-name> with "y" command and then using "/<string-pattern>" will leads to Pressing "<register-name> with "y" command and then using "/<string-pattern>" will leads to
yanking(copying) from the current cursor position to the next occurance of the <string-pattern>. yanking(copying) from the current cursor position to the next occurance of the <string-pattern>.
@ Command : [range]s/<old>/<new>/[flag] (Its a line command)
^ ^
| |
optional optional
What does it do?
It replace the occurance of old string to new string over the range
in the file.
[flag]
* g : It represent to replace all the occurance of <old> to <new> in
current line where the cursor is present.
[range]
Define the range of this command. Could be single line, multiple line
and even all the lines in the file, etc.
* <line-number> : On which line number this command to be executed.
* <start-line-number>,<end-line-number> : From the starting line number
to the ending line number to
to execute the command.
For ex:
:1s/<old>/<new>/g
It will replace <old> with <new> in the entire line of line number 1.
:1,5s/<old>/<new>/g
It will do the same form line number 1 to 5.