Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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
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. :)) – lord.garbage 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.