# Commenting out a block of code

**URL:** <https://forum.inductiveautomation.com/t/commenting-out-a-block-of-code/3840>\
**Category:** Ignition\
**Created:** [January 10, 2012, 10:06pm UTC](https://forum.inductiveautomation.com/t/commenting-out-a-block-of-code/3840 "2012-01-10T22:06:24Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Nate.Olson](https://avatars.discourse-cdn.com/v4/letter/n/35a633/32.png) [@Nate.Olson](https://forum.inductiveautomation.com/u/Nate.Olson)\
**Post date:** [January 10, 2012, 10:06pm UTC](https://forum.inductiveautomation.com/t/commenting-out-a-block-of-code/3840/1 "2012-01-10T22:06:24Z")

</div>

Is there a way to comment out a block of code in the script editor rather than using the # character for each line?

Thanks,  
Nate

---

<div class="post-metadata">

**Author:** ![dave.fogle](https://avatars.discourse-cdn.com/v4/letter/d/43a26b/32.png) [@dave.fogle](https://forum.inductiveautomation.com/u/dave.fogle)\
**Post date:** [January 10, 2012, 10:11pm UTC](https://forum.inductiveautomation.com/t/commenting-out-a-block-of-code/3840/2 "2012-01-10T22:11:41Z")

</div>

You can highlight the block of code and then do a Ctrl+/ to comment the entire block quickly, then to un-comment, highlight the entire block and press Ctrl+Shift+/ . Still uses # characters but it's quick. Hope this helps.

---

<div class="post-metadata">

**Author:** ![pascal](https://avatars.discourse-cdn.com/v4/letter/p/e9a140/32.png) [@pascal](https://forum.inductiveautomation.com/u/pascal)\
**Post date:** [July 26, 2017, 2:03pm UTC](https://forum.inductiveautomation.com/t/commenting-out-a-block-of-code/3840/3 "2017-07-26T14:03:28Z")

</div>

I know it is old but maybe someone can help, I tried to do as suggested above but nothing happened…any suggestion? By the way, my keyboard is in AZERTY mode

---

<div class="post-metadata">

**Author:** ![michael.biggers](https://avatars.discourse-cdn.com/v4/letter/m/ecae2f/32.png) [@michael.biggers](https://forum.inductiveautomation.com/u/michael.biggers)\
**Post date:** [July 26, 2017, 2:29pm UTC](https://forum.inductiveautomation.com/t/commenting-out-a-block-of-code/3840/4 "2017-07-26T14:29:29Z")

</div>

Another way to comment out the block of code, which might work better for you, is by turning it into a string with triple quotes.  
If you go to the very beginning of the block of code you want to comment out and type “”" that turns everything from that point onward in your code into a string. Then, you can go to the end of the block you want commented out and put another “”" to signify the end of the string. Since that whole block is now turned into a string, it is effectively commented out of your code. It’s a nice Python trick to know 🙂

---

<div class="post-metadata">

**Author:** ![pascal](https://avatars.discourse-cdn.com/v4/letter/p/e9a140/32.png) [@pascal](https://forum.inductiveautomation.com/u/pascal)\
**Post date:** [July 26, 2017, 2:58pm UTC](https://forum.inductiveautomation.com/t/commenting-out-a-block-of-code/3840/5 "2017-07-26T14:58:51Z")

</div>

This works fine, thanks !

---

<div class="post-metadata">

**Author:** ![luca.mori](https://avatars.discourse-cdn.com/v4/letter/l/5daacb/32.png) [@luca.mori](https://forum.inductiveautomation.com/u/luca.mori)\
**Post date:** [June 4, 2019, 8:58am UTC](https://forum.inductiveautomation.com/t/commenting-out-a-block-of-code/3840/6 "2019-06-04T08:58:47Z")

</div>

I do it this way,  
I select the portion of the code i need to comment, starting from the bottom ( don’t ask me why, just trust me ), then i press ctrl + \ and then type # on multiple lines.

---

<div class="post-metadata">

**Author:** ![samer\_samy](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/samer_samy/32/52910_2.png) [@samer\_samy](https://forum.inductiveautomation.com/u/samer_samy)\
**Post date:** [July 26, 2023, 8:31am UTC](https://forum.inductiveautomation.com/t/commenting-out-a-block-of-code/3840/7 "2023-07-26T08:31:00Z")

</div>

It worked this way ,thanks luca 😀

---

<div class="post-metadata">

**Author:** ![Daniele\_Belardinelli](https://avatars.discourse-cdn.com/v4/letter/d/bc79bd/32.png) [@Daniele\_Belardinelli](https://forum.inductiveautomation.com/u/Daniele_Belardinelli)\
**Post date:** [October 4, 2023, 9:38am UTC](https://forum.inductiveautomation.com/t/commenting-out-a-block-of-code/3840/8 "2023-10-04T09:38:48Z")

</div>

it doesn't work for me, how did you do that?

---

<div class="post-metadata">

**Author:** ![pascal.fragnoud](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pascal.fragnoud/32/24728_2.png) [@pascal.fragnoud](https://forum.inductiveautomation.com/u/pascal.fragnoud)\
**Post date:** [October 4, 2023, 9:48am UTC](https://forum.inductiveautomation.com/t/commenting-out-a-block-of-code/3840/9 "2023-10-04T09:48:31Z")

</div>

If you do this in the script console, the whole block will be printed as a string.  
To avoid this, assign the whole thing to a variable:

```python
_ = """
...
whole block of code
...
"""

```

---

<div class="post-metadata">

**Author:** ![samer\_samy](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/samer_samy/32/52910_2.png) [@samer\_samy](https://forum.inductiveautomation.com/u/samer_samy)\
**Post date:** [October 4, 2023, 11:06am UTC](https://forum.inductiveautomation.com/t/commenting-out-a-block-of-code/3840/10 "2023-10-04T11:06:12Z")

</div>

[https://us1.discourse-cdn.com/inductiveautomation/original/3X/f/3/f323ee559c8a2623be8377d5990c1057ce45b319.mp4](https://us1.discourse-cdn.com/inductiveautomation/original/3X/f/3/f323ee559c8a2623be8377d5990c1057ce45b319.mp4)

just as luca said , select the portion of the code i need to comment, starting from the bottom , then press ctrl + \

check the video

---

<div class="post-metadata">

**Author:** ![lrose](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/lrose/32/62724_2.png) [@lrose](https://forum.inductiveautomation.com/u/lrose)\
**Post date:** [October 4, 2023, 1:27pm UTC](https://forum.inductiveautomation.com/t/commenting-out-a-block-of-code/3840/11 "2023-10-04T13:27:35Z")

</div>

It's possible if you have a different Keyboard layout that you need a different key combination, in order to do this.

---

<div class="post-metadata">

**Author:** ![justinedwards.jle](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/justinedwards.jle/32/37854_2.png) [@justinedwards.jle](https://forum.inductiveautomation.com/u/justinedwards.jle)\
**Post date:** [October 4, 2023, 1:35pm UTC](https://forum.inductiveautomation.com/t/commenting-out-a-block-of-code/3840/12 "2023-10-04T13:35:28Z")

</div>

> [@lrose](#):
>
> a different key combination

Does this work for you on your keyboard?

---

<div class="post-metadata">

**Author:** ![pascal.fragnoud](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pascal.fragnoud/32/24728_2.png) [@pascal.fragnoud](https://forum.inductiveautomation.com/u/pascal.fragnoud)\
**Post date:** [October 4, 2023, 1:44pm UTC](https://forum.inductiveautomation.com/t/commenting-out-a-block-of-code/3840/13 "2023-10-04T13:44:11Z")

</div>

I never had an issue with ctrl + / to comment things, but I'm on a qwerty.  
I know my fellow Frenchies can't do it with the regular azerty layouts we have in France.

---

<div class="post-metadata">

**Author:** ![Felipe\_CRM](https://avatars.discourse-cdn.com/v4/letter/f/dfb087/32.png) [@Felipe\_CRM](https://forum.inductiveautomation.com/u/Felipe_CRM)\
**Post date:** [October 4, 2023, 1:44pm UTC](https://forum.inductiveautomation.com/t/commenting-out-a-block-of-code/3840/14 "2023-10-04T13:44:35Z")

</div>

EDIT: These don't seem to actually work, unfortunately, thanks @pascal.fragnoud. Leaving in for future reference

> [@Coming in 8.1.18: Script editor improvements](https://forum.inductiveautomation.com/t/coming-in-8-1-18-script-editor-improvements/59629/6):
>
> [French keyboard] Image source: [AZERTY - Wikipedia](https://en.wikipedia.org/wiki/AZERTY). @mazeyrat, a quick web search reveals that the non-English keyboard layouts have been a problem in other softwares’ keyboard shortcuts too. The problem appears to be that you’re having to use the Shift key and this messes up the keycodes. (I can’t remember how exactly this works but the character is returned along with the status of the Ctrl, Shift and Alt keys.) Some posts suggest that if you have a number keypad that Ctrl-/ or Ctrl-÷ or if…

@Transistor suggested a couple possibilities awhile back but not sure if they have been confirmed to work or not.

---

<div class="post-metadata">

**Author:** ![justinedwards.jle](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/justinedwards.jle/32/37854_2.png) [@justinedwards.jle](https://forum.inductiveautomation.com/u/justinedwards.jle)\
**Post date:** [October 4, 2023, 1:47pm UTC](https://forum.inductiveautomation.com/t/commenting-out-a-block-of-code/3840/15 "2023-10-04T13:47:09Z")

</div>

> [@samer\_samy](#):
>
> then press ctrl + \

This threw me off. It's` ctrl + /`. It works for me this way.

---

<div class="post-metadata">

**Author:** ![samer\_samy](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/samer_samy/32/52910_2.png) [@samer\_samy](https://forum.inductiveautomation.com/u/samer_samy)\
**Post date:** [October 4, 2023, 1:48pm UTC](https://forum.inductiveautomation.com/t/commenting-out-a-block-of-code/3840/16 "2023-10-04T13:48:22Z")

</div>

sorry, it is ctrl + / , you are right , I did not notice this mistake

---

<div class="post-metadata">

**Author:** ![pascal.fragnoud](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pascal.fragnoud/32/24728_2.png) [@pascal.fragnoud](https://forum.inductiveautomation.com/u/pascal.fragnoud)\
**Post date:** [October 4, 2023, 1:50pm UTC](https://forum.inductiveautomation.com/t/commenting-out-a-block-of-code/3840/17 "2023-10-04T13:50:41Z")

</div>

I just switched to azerty (which I need to keep for accents **éùöî** , you should see me switch between layouts every 1.2 seconds when I need to type something in French. It's not pretty. On Linux I switch to an international layout that allows me to type accents, but I couldn't find something that works well on Windows) to try and none of the combinations worked.

---

<div class="post-metadata">

**Author:** ![lrose](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/lrose/32/62724_2.png) [@lrose](https://forum.inductiveautomation.com/u/lrose)\
**Post date:** [October 4, 2023, 2:00pm UTC](https://forum.inductiveautomation.com/t/commenting-out-a-block-of-code/3840/18 "2023-10-04T14:00:59Z")

</div>

I use a standard qwerty setup and `ctrl+/` works as expected for me, but I know that different layouts, such as apparently French AZERTY will send a different character code for the same key combination and that can sometimes result in shortcuts not working as expected.

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [October 4, 2023, 2:39pm UTC](https://forum.inductiveautomation.com/t/commenting-out-a-block-of-code/3840/19 "2023-10-04T14:39:06Z")

</div>

> [@pascal.fragnoud](#):
>
> On Linux I switch to an international layout that allows me to type accents

I type accents with a compose key on Linux. (I use the windows key as compose, since it's just sitting there.)

áèïöçñ

---

<div class="post-metadata">

**Author:** ![pascal.fragnoud](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pascal.fragnoud/32/24728_2.png) [@pascal.fragnoud](https://forum.inductiveautomation.com/u/pascal.fragnoud)\
**Post date:** [October 4, 2023, 2:40pm UTC](https://forum.inductiveautomation.com/t/commenting-out-a-block-of-code/3840/20 "2023-10-04T14:40:36Z")

</div>

Don't make me learn yet another layout/method, I'm full 😬

[Next page](https://forum.inductiveautomation.com/t/commenting-out-a-block-of-code/3840.md?page=2)
