![]() Refer to Emacs manual and help pages to learn more. 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. If you have auto-fill-mode turned on (see How do I turn on auto-fill-mode by default), you can tell Emacs to prefix every line with a certain character sequence, the fill prefix. 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. This makes it possible to get the full benefit of Adaptive Fill mode in Text mode, and other modes derived from it (such as Mail mode). The following is from the NEWS file for Emacs 20.2: 'In Text mode, now only blank lines separate paragraphs. ![]() 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. Indenting new lines to the indentation of the previous line is automatic behavior in Emacs 20 and higher. As ocp-indent is a command-line tool, you can easily integrate it with other. NOTE: If the line is commented out, Emacs will uncomment it. Run the following command to setup tuareg-mode to use ocp-indent. 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.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |