Skip to content
Advertisement

How to substitute text which has implicit meaning in vi

I have a C code in vi from which I want to replace the text “n” with something else. Use of %s:n:(anything else) isn’t working. Is there any way to bypass this?

For example,a line in the code is: printf(“Hello worldn”); In vi, I need to replace “n” in the printf line with a full stop. Use of substitue command (%s:n:.) will not work for “n”

Please let me know what is the command to replace ‘text’ which also has some implicit meaning in vi (here n is newline is vi as well). Thanks in advance!

Advertisement

Answer

You need to escape the backslash in n, like this:

%s:\n:.
User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement