VIM: Replace all occurrences of a word in the current C / C ++ function

I have to replace all occurrences of a specific macro inside some (only some of the dozens) functions of C. Since the file lasts thousands of lines, and all functions have several instances of the macro, I would like to replace all occurrences in the specific function that the cursor is currently placing . I know that VIM provides navigation commands (for example, [[go to the beginning of the current function, and then% to find its suitable closing bracket), but I cannot figure out how to use them to search for the required search, replace the command. Can anyone help?

+3
source share
2 answers

. v%, , . :s/find/replace/g enter. .

. , : :'<,'>:s/find/replace/g.

+12

dogbane, , NrrwRgn. .

+2

Source: https://habr.com/ru/post/1792455/


All Articles