<p>The <a href="https://github.com/craftcms/redactor#redactor-configs" rel="nofollow noreferrer">redactor configs</a> are stored inside the <code>config/redactor</code> directory.</p>
<p>Make sure you're editing the right config that your field uses (eg Standard) and add:</p>
<pre><code>  &quot;minHeight&quot;:&quot;500px&quot;,
</code></pre>
<p>... to that file. The configs use JSON so when you see a Redactor configuration, that's how Craft is going to initialize it.</p>
<p>To answer your other question, Redactor is not really designed as a code editor—it's really for end users editing text in a WYSIWYG fashion.</p>
<p>I was able to get Redactor to keep line breaks in tact and keep comments using something like:</p>
<pre><code>  &quot;cleanOnEnter&quot;: false,
  &quot;removeComments&quot;: false
</code></pre>
<p>You might also want to turn off HTML purifier (or modify its own config).</p>
<p>FWIW it's probably much easier to use a dedicated field type for editing code, such as the <a href="https://plugins.craftcms.com/code-mirror" rel="nofollow noreferrer">CodeMirror</a> plugin.</p>

CC BY-SA 4.0
2020-06-30T01:22:54.013Z
The min-height worked, thank you. I have the HTML purifier off but it still removed line breaks after adding those other two lines. That's okay though, I'm going to check out the CodeMirror plugin.  Thanks!
Jake1293
CC BY-SA 4.0
2020-06-29T18:26:58.637Z
2020-06-29T18:26:58.637Z
RitterKnight
<p>I'm looking to set a min height on the redactor text area.  The <a href="https://imperavi.com/redactor/docs/settings/height-and-width/" rel="nofollow noreferrer">vendor site</a> shows how it can be done, but doesn't specify where to add this code snippet.</p>
<pre><code>$R('#content', {
  minHeight: '500px'
});
</code></pre>
<p>I added that to the redactor.js file in the vendor/craftcms/redactor/lib/redactor folder, but it didn't work. Can someone point me in the right direction? I'm trying to avoid installing additional plugins like Control Panel CSS just to do that one thing.</p>
<p>Additionally, is there a way to preserve line breaks in the text area? I work only in the code view mode and after every save, line breaks disappear. I did a search and found some pages on Github that talk about the issue, but I couldn't find a resolution.</p>

<redactor><css>
Redactor: Set a min height and preserve line breaks
# Redactor: Set a min height and preserve line breaks

(Asked by: username_0 on 2020-06-28)

I'm looking to set a min height on the redactor text area.  The vendor site shows how it can be done, but doesn't specify where to add this code snippet.
$R('#content', {
  minHeight: '500px'
});

I added that to the redactor.js file in the vendor/craftcms/redactor/lib/redactor folder, but it didn't work. Can someone point me in the right direction? I'm trying to avoid installing additional plugins like Control Panel CSS just to do that one thing.
Additionally, is there a way to preserve line breaks in the text area? I work only in the code view mode and after every save, line breaks disappear. I did a search and found some pages on Github that talk about the issue, but I couldn't find a resolution.

**Tags:** redactor, css


---

## 1 answers

### Answer by username_1 on 2020-06-29. Score: 3 | Accepted answer

The redactor configs are stored inside the config/redactor directory.
Make sure you're editing the right config that your field uses (eg Standard) and add:
  "minHeight":"500px",

... to that file. The configs use JSON so when you see a Redactor configuration, that's how Craft is going to initialize it.
To answer your other question, Redactor is not really designed as a code editor—it's really for end users editing text in a WYSIWYG fashion.
I was able to get Redactor to keep line breaks in tact and keep comments using something like:
  "cleanOnEnter": false,
  "removeComments": false

You might also want to turn off HTML purifier (or modify its own config).
FWIW it's probably much easier to use a dedicated field type for editing code, such as the CodeMirror plugin.

> **Comments:**
> **username_0**: The min-height worked, thank you. I have the HTML purifier off but it still removed line breaks after adding those other two lines. That's okay though, I'm going to check out the CodeMirror plugin.  Thanks!  

---

