Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Regex Question: how do I replace a single space with a newline in VI

Tags:

regex

vim

Regex Question: how do I replace a single space with a newline in VI.

like image 479
user267324 Avatar asked Feb 05 '10 18:02

user267324


1 Answers

:%s/ /^V^M/g

note: hit ctrl-v, ctrl-m.

edit: if you really mean all single spaces, meaning spaces not followed by another space, use this:

:%s/ \{1\}/^V^M/g

and if you really meant just the first single space in the document, use this:

:%s/ /^V^M/

like image 140
glomad Avatar answered Sep 22 '22 21:09

glomad