# Comment fonctionne la fonction de surlignage automatique de tout le code ?

**URL:** https://meta.discourse.org/t/how-does-auto-highlight-all-code-works/58368
**Category:** Support
**Created:** [Mars 4, 2017, 9:07 UTC](https://meta.discourse.org/t/how-does-auto-highlight-all-code-works/58368 "2017-03-04T21:07:29Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![zbor](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/zbor/32/67843_2.png) [@zbor](https://meta.discourse.org/u/zbor)
#### Post date: [Mars 4, 2017, 9:07 UTC](https://meta.discourse.org/t/how-does-auto-highlight-all-code-works/58368/1 "2017-03-04T21:07:29Z")

</div>

I would like to turn autohighlight for Microsoft Visual Basic for Applications (VBA)

 ![](https://global.discourse-cdn.com/meta/original/3X/6/1/6180dd8129ceb9163fe029c163f23e77fda1ef00.png)

but it doesn’t work as expected.

As I see it only works if code is indented.  
But if that’s true why language recognition?

Could it be forced to recognize language?

Is it possible that first post in this thread [https://online-excel-solutions.com/t/preformatted-text-vba-testing/358](https://online-excel-solutions.com/t/preformatted-text-vba-testing/358) is automatically preformatted?

---

<div class="post-metadata">

### Author: ![Mittineague](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mittineague/32/114259_2.png) [@Mittineague](https://meta.discourse.org/u/Mittineague)
#### Post date: [Mars 4, 2017, 9:22 UTC](https://meta.discourse.org/t/how-does-auto-highlight-all-code-works/58368/2 "2017-03-04T21:22:45Z")

</div>

I don’t know if the code highlighting works with indented code blocks. You may need to use three backticks eg. ```vb

```vb
Sub test()
Dim x As Long

With ActiveCell
For i = 1 To 1000
x = 91 * i
If Right(x, 2) = "22" Then
ActiveCell.Offset(m).Value = i
m = m + 1
End If
Next i

End With

End Sub

```

---

<div class="post-metadata">

### Author: ![zbor](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/zbor/32/67843_2.png) [@zbor](https://meta.discourse.org/u/zbor)
#### Post date: [Mars 4, 2017, 9:26 UTC](https://meta.discourse.org/t/how-does-auto-highlight-all-code-works/58368/3 "2017-03-04T21:26:41Z")

</div>

I know that.  
I meant that this would automatically recognize language and then code it.

Both codes in mine above link are just copy-paste. Without \< / \>.

In second post it format some parts by itself.

---

<div class="post-metadata">

### Author: ![Mittineague](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mittineague/32/114259_2.png) [@Mittineague](https://meta.discourse.org/u/Mittineague)
#### Post date: [Mars 4, 2017, 9:39 UTC](https://meta.discourse.org/t/how-does-auto-highlight-all-code-works/58368/4 "2017-03-04T21:39:42Z")

</div>

All `</>` does is indent whatever is selected four spaces.  
If what is pasted in has lines that are indented four spaces they will be seen the same as if they had been selected and then indented. A common gotcha is pasted in code with # comments and underscores that get seen as intentional Markdown syntax when they are not.

I don’t know what the “generic” highlighter highlights other than Strings, Ints, and certain words common to various languages.

---

<div class="post-metadata">

### Author: ![cpradio](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/cpradio/32/4970_2.png) [@cpradio](https://meta.discourse.org/u/cpradio)
#### Post date: [Mars 4, 2017, 10:00 UTC](https://meta.discourse.org/t/how-does-auto-highlight-all-code-works/58368/5 "2017-03-04T22:00:31Z")

</div>

IIRC, that setting is there so it will apply code formatting/highlighting to space indented code and fenced code blocks. On Meta, that setting is not enabled.

Space indented

```
if (true) {
  this_is_formatted = true;
}

```

Fenced code block

```plaintext
if (true) {
  this_is_formatted = true;
}

```

Where as on my sandbox with it enabled, I get

 ![](https://global.discourse-cdn.com/meta/original/3X/e/b/eb0467d773f2f799fbb56e92383017c630034350.png)

---

<div class="post-metadata">

### Author: ![zbor](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/zbor/32/67843_2.png) [@zbor](https://meta.discourse.org/u/zbor)
#### Post date: [Mars 4, 2017, 10:12 UTC](https://meta.discourse.org/t/how-does-auto-highlight-all-code-works/58368/6 "2017-03-04T22:12:19Z")

</div>

OK, so it means, when automatically set, it will change code block to fancy if space indented?

---

<div class="post-metadata">

### Author: ![cpradio](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/cpradio/32/4970_2.png) [@cpradio](https://meta.discourse.org/u/cpradio)
#### Post date: [Mars 4, 2017, 10:17 UTC](https://meta.discourse.org/t/how-does-auto-highlight-all-code-works/58368/7 "2017-03-04T22:17:26Z")

</div>

Yes. That is correct.

---

<div class="post-metadata">

### Author: ![JammyDodger](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jammydodger/32/254611_2.png) [@JammyDodger](https://meta.discourse.org/u/JammyDodger)
#### Post date: [Juin 8, 2024, 12:44 UTC](https://meta.discourse.org/t/how-does-auto-highlight-all-code-works/58368/8 "2024-06-08T12:44:59Z")

</div>

Ce sujet a été automatiquement fermé après 2652 jours. Les nouvelles réponses ne sont plus autorisées.
