mirror of
https://github.com/Hizenberg469/Vim-tutorials.git
synced 2026-04-19 22:02:24 +03:00
Transforming and Substituting Text Complete
This commit is contained in:
55
vim-commands
55
vim-commands
@@ -490,6 +490,8 @@ Line mode:
|
||||
and even all the lines in the file, etc.
|
||||
|
||||
* <line-number> : On which line number this command to be executed.
|
||||
To execute the command on same line as cursor,
|
||||
don't mention <line-number>.
|
||||
|
||||
* <start-line-number>,<end-line-number> : From the starting line number
|
||||
to the ending line number to
|
||||
@@ -503,3 +505,56 @@ Line mode:
|
||||
:1,5s/<old>/<new>/g
|
||||
|
||||
It will do the same form line number 1 to 5.
|
||||
|
||||
:/<Pattern-1>/,/<Pattern-2>/s/<old>/<new>/g
|
||||
|
||||
It will do the same from line which has pattern matching with
|
||||
with <Pattern-1> and ending with line which has pattern
|
||||
matching with pattern <Pattern-2>.
|
||||
|
||||
|
||||
------------------------------------
|
||||
|
||||
|
||||
$ = last line; . = current line
|
||||
|
||||
:.,$s/<old>/<new>/g
|
||||
|
||||
% = All the line (entire file)
|
||||
|
||||
:%s/<old>/<new>/g
|
||||
|
||||
-----------------------------------
|
||||
|
||||
|
||||
For including character such as "/" for <old> and <new>
|
||||
we can use "\" which is a escape character.
|
||||
|
||||
For ex:
|
||||
|
||||
:s/\/<old>\//\/<new>\//
|
||||
|
||||
OR
|
||||
|
||||
we can use other non-alphanumeric character as a separator.
|
||||
|
||||
For ex:
|
||||
|
||||
:s#/<old>/#/<new>/
|
||||
|
||||
%% TIPS %%
|
||||
|
||||
To set options in VIM, we can use :set <option> command.
|
||||
|
||||
* To set a option to show the line number of the current opened file in the vim
|
||||
we use:
|
||||
:set nu
|
||||
|
||||
* To undo this:
|
||||
|
||||
:set nonu
|
||||
* To toggle the current configuration.
|
||||
|
||||
:set nu!
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user