mirror of
https://github.com/Hizenberg469/Vim-tutorials.git
synced 2026-04-19 22:02:24 +03:00
Subsituting in the entire file
This commit is contained in:
38
vim-commands
38
vim-commands
@@ -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.
|
||||||
|
|||||||
Reference in New Issue
Block a user