Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

How to insert newlines in vim?

For example in a file containing

test-classes; classes; xmlunit-1.3.jar

I am looking for the vim equivalent of sed command

sed -i 's/; /\n/g' classpath

to obtain

test-classes
classes
xmlunit-1.3.jar
share|improve this question
add comment

1 Answer

up vote 3 down vote accepted

You almost got it right, just use \r instead of \n:

:%s/; /\r/g
share|improve this answer
3  
For non-vim variants of vi, you'd probably need to use a literal newline character instead of \r - which you can obtain by typing Ctrl-V Ctrl-M. This will display as ^M. –  D_Bye Dec 7 '12 at 10:37
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.