

It enables syntax highlighting when writing code or editing configuration files. It is one the most popular and widely used text editors among System Administrators and programmers that is why many users often refer to it as a programmer’s editor. Vim is a powerful command-line based text editor that has enhanced the functionalities of the old Unix Vi text editor. In this article, I am taking a look at some of the best 21 open-source commonly used text editors in Linux on both servers and desktops. Refer to Emacs manual and help pages to learn more.Don’t Miss: My Favorite Command-Line Editors for Linux – What’s Your Editor? Emacs is a great tool and very useful when working in the terminal. In this guide, we discussed various ways to comment out a single line or multiple lines at once in the Emacs text editor. To comment out only the highlighted region, use the ALT + key.Īs you can see, Emacs only comments out the select part of the code. For example, consider the following selected region. If you want to comment out only the selected region, you can use the ALT + key. How to Comment a Region of code In EmacsĪs mentioned above, the CTRL + key in Emacs comments out the entire line where the cursor or the region is located. So, if the cursor is at the end of the line, the whole line will be commented or uncommented out. It is good to note that the CTRL + X and CTRL + keys always operate on the set line.

Once you have the target region selected, use the CTRL + X and CTRL + to comment out the region as: Doing this will start the selection, and you can use the up and down arrow keys to select the region. To comment on a specific block of code, start by selecting the region you wish to comment out by pressing CTRL + SPACE. Start by pressing the CTRL + U key, followed by the number of lines to comment out.įinally, press CTRL + X and then CTRL + Īs you can see from the screenshot above, Emacs comments out 10 lines from the current cursor position. How to Comment a Specified Number of Lines In EmacsĮmacs also allows you to pass the number of lines you need to comment or uncomment. NOTE: If the line is commented out, Emacs will uncomment it. This comments out the current line and goes to the following line. To comment out a single line of code using Emacs, press CTRL + X and then CTRL + Having this skill will help improve your Emacs workflow and skill. This tutorial will show you how to comment out code using the Emacs editor. However, many users tend to shy away from using Emacs because of its unconventional use of shortcuts for basic commands. It comes in Graphical and command-line versions, making it suitable for both terminal and Graphical users.
