Sign up ×
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.

Given a string like:

"Hello World, how are you today?"

Is there a way in Vim to collapse this line vertically such that every word appears on a new line, i.e.:


I had something similar in mind like executing Ctrl-V + Ctrl-gq which wraps lines relative to a fixed width which can be set in .vimrc.

share|improve this question

1 Answer 1

up vote 7 down vote accepted

You can do this by replacing the spaces in the line with newlines.


This will replace on all lines(%s), all spaces (\s) with newlines (\r).

You can remove the percent sign to limit the replacement to the current line.

share|improve this answer
Very nice! Simple and elegant. (Be patient, I can accept your answer in five minutes. :)) – brauner Jun 11 '14 at 15:29

Your Answer


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.