To replace a block of text into String in vim, try the following commands:
:%s/\/\/gc
:%s/\n/\n” +\r”/gc
To replace specific string into another in lots of files, e.g. replace *.java’s package name “net.sf.j2s.” into another name “org.java2script.”, follow the instructions:
- Select all the *.java in Explorer, and open them with single vim
- :map <F9> :%s/net\.sf\.j2s\./org\.java2script\./g<CR>:w<CR>:n<CR>
- Press <F9> many times as the count of *.java files
This tricks can also be used in similar tasks.