<p>From question <em><a href="https://stackoverflow.com/questions/71323/how-to-replace-a-character-for-a-newline-in-vim">How to replace a character for a newline in Vim?</a></em>. You have to use \r when replacing text for a newline, like this</p>

<pre><code>:%s/%/\r/g
</code></pre>

<p>But when replacing end of lines and newlines for a character, you can do it like:</p>

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

<p>What section of the manual documents these behaviors, and what's the reasoning behind them?</p>

```
:help NL-used-for-Nul
```
Technical detail:
```
<Nul>
```
characters in the file are stored as
```
<NL>
```
in memory. In the display
  they are shown as "
```
^@
```
".  The translation is done when reading and writing
  files.  To match a
```
<Nul>
```
with a search pattern you can just enter
CTRL-@
or
  "
CTRL-V
000".  This is probably just what you expect.  Internally the
  character is replaced with a
```
<NL>
```
in the search pattern.  What is unusual is
  that typing
CTRL-V
CTRL-J
also inserts a
```
<NL>
```
, thus also searches for a
```
<Nul>
```
in the file.  {Vi cannot handle
```
<Nul>
```
characters in the file at all}