How to detect regexp lines of code in VIM

I have so many println (") in my codes .. I know this is dirty ... I want to put a comment for each of println (" ");

how to do it in vim? I want to say that I want to do this on multiple files.

Also, if possible, can it determine if the lines have // ​​already or not ... if the lines have been commented out .. I don't want to add new //

+3
source share
2 answers

To add //commentto all unauthorized calls println(...)in your lines:

:%s/^\(\s*println(.*);\)\s*$/\1\/\/comment/gc

To comment on all undocumented calls println(...)in their own lines

:%s/^\(\s*println(.*);\)\s*$/\/\/\1/gc
+2

:

:g|println|normal I//

: g (: normal I//) , ( println).

, , : bufdo:

:bufdo g|println|normal I//

Amarghosh :

:bufdo g|\s*println(.*);|normal I//
0

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


All Articles