Open practicalli-johnny opened 1 year ago
Neovim built-in substitution command
:%s command substitutes text in the current buffer, e.g substitute the word have by had
:%s
:%s/have/had/g`
The g modifier replaced all occurrences on the same line, omitting g only replaces the first occurrence on each line.
g
c modifier prompts for confirmation of each replace occurrence.
Use visual select to replace all of the 32 arguments to functions by 100 without replacing 32 in the declarations
let = 32; let = 32; let _ = 32;
let x = foo(32); let y = bar(32); let z = zoo(32); let a = quux(32); let b = tronfibulate(32);
Select all the lines starting from let x = … to let b = … and press :
:
enter the substitute command to scope it to that selection;
% means the whole file
:'<,'>, are visual marks.
Using visual select the substitute command
:'<,'>s/32/100/g
the replacement was limited to the portion of text selected. That works in visual, line and block visual modes
:help s_flags for more information about the substitute flags.
:help s_flags
Neovim built-in substitution command
:%s
command substitutes text in the current buffer, e.g substitute the word have by hadThe
g
modifier replaced all occurrences on the same line, omitting g only replaces the first occurrence on each line.c modifier prompts for confirmation of each replace occurrence.
Use visual select to replace all of the 32 arguments to functions by 100 without replacing 32 in the declarations
let = 32; let = 32; let _ = 32;
let x = foo(32); let y = bar(32); let z = zoo(32); let a = quux(32); let b = tronfibulate(32);
Select all the lines starting from let x = … to let b = … and press
:
enter the substitute command to scope it to that selection;
% means the whole file
:'<,'>, are visual marks.
Using visual select the substitute command
the replacement was limited to the portion of text selected. That works in visual, line and block visual modes
:help s_flags
for more information about the substitute flags.