Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Substitution in neovim #33

Open
practicalli-johnny opened this issue Apr 12, 2023 · 0 comments
Open

Substitution in neovim #33

practicalli-johnny opened this issue Apr 12, 2023 · 0 comments

Comments

@practicalli-johnny
Copy link
Contributor

Neovim built-in substitution command

:%s command substitutes text in the current buffer, e.g substitute the word have by had

:%s/have/had/g`

The 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

:'<,'>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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Todo
Development

No branches or pull requests

1 participant