<p>I'm trying to replace each <code>,</code> in the current file by a new line:</p>

<pre><code>:%s/,/\n/g 
</code></pre>

<p>But it inserts what looks like a <code>^@</code> instead of an actual newline. The file is not in DOS mode or anything.</p>

<p>What should I do?</p>

<p>If you are curious, like me, check the question <em><a href="https://stackoverflow.com/questions/71417/why-is-r-a-newline-for-vim">Why is \r a newline for Vim?</a></em> as well.</p>

Use
```
\r
```
instead of
```
\n
```
.
Substituting by
```
\n
```
inserts a null character into the text. To get a newline, use
```
\r
```
. When
searching
for a newline, you’d still use
```
\n
```
, however. This asymmetry is due to the fact that
```
\n
```
and
```
\r
```
do slightly different things
:
```
\n
```
matches an end of line (newline), whereas
```
\r
```
matches a carriage return. On the other hand, in substitutions
```
\n
```
inserts a null character whereas
```
\r
```
inserts a newline (more precisely, it’s treated as the input
CR
). Here’s a small, non-interactive example to illustrate this, using the Vim command line feature (in other words, you can copy and paste the following into a terminal to run it).
```
xxd
```
shows a hexdump of the resulting file.
```
```
echo bar > test
(echo 'Before:'; xxd test) > output.txt
vim test '+s/b/\n/' '+s/a/\r/' +wq
(echo 'After:'; xxd test) >> output.txt
more output.txt
```
```
```
```
Before:
0000000: 6261 720a                                bar.
After:
0000000: 000a 720a                                ..r.
```
```
In other words,
```
\n
```
has inserted the byte 0x00 into the text;
```
\r
```
has inserted the byte 0x0a.