Dynamics 365 Business Central: How to quickly comment one or more lines of code in AL – Comment/uncomment Selection

Dynamics 365 Business Central

Hi, Readers.
Today I would like to share another tip about Business Central. During the development, how to quickly comment one or more lines of code in AL.
I was asked this question recently and found that there are still BC developers who don’t know, so I will briefly share it.

In computer programming, a comment is a programmer-readable explanation or annotation in the source code of a computer program. They are added with the purpose of making the source code easier for humans to understand, and are generally ignored by compilers and interpreters. The syntax of comments in various programming languages varies considerably.

In AL Language we commonly use the following two ways.
1. Single-line comments (Line Comment): delimited by //

2. Multi-line comments (Block Comment): delimited by /* and */

If you have experience in NAV development, you must still remember that we can comment the code in the following way

  • To comment lines of code: Select the lines, and then choose Comment Selection in the Edit menu (Shift+Ctrl+K)
  • To uncomment lines of code: Select the lines, and then choose Uncomment Selection in the Edit menu (Shift+Ctrl+O)

How to do this in VS Code? It’s not very difficult either. These menus also exist in VS Code and are available in two ways.

1. Select the lines, and then choose Toggle Line Comment in the Edit menu (Ctrl+/)

The selected lines will be commented out. (//)

After clicking again, the selected lines will be uncommented.

2. Select the lines, and then choose Toggle Block Comment in the Edit menu (Shift+Alt+A)

The selected lines will be block commented out. (/* and */)

Like the first method, it will be restored after clicking again.

There is also a method that comes with OS. For example, in Windows, if you want to quickly comment one or more lines of code, you can press Ctrl + K, C (Hold down Ctrl and hit K followed by C)

To uncomment one or more lines of code, press Ctrl + K, U (Hold down Ctrl and hit K followed by U)

Test video: Youtube

Business Central short video: Quickly comment one or more lines of code in AL (Comment/uncomment)

Very simple, give it a try!!!😁

PS:
Visual Studio Code: Keyboard shortcuts for Windows

Visual Studio Code: Keyboard shortcuts for macOS

END

Hope this will help.

Thanks for reading.

ZHU

コメント

Copied title and URL