is for distinguishing comment lines from code. Emacs uses the same key bindings for manipulating comments in different modes. Emacs handles all the different ways of inserting comments for each of the major modes. Use additional tags to indicate language-specific modes for questions about comments.
Questions tagged [comment]
143 questions
19
votes
2 answers
How to detect if the point is within a comment area?
How to detect if the point is within a comment area?

Name
- 7,849
- 4
- 41
- 87
5
votes
0 answers
How to setup comment-start and comment-start-skip?
Haskell has line comments starting with -- and multiline comments of the form {- ... -}. I'd like to make auto-fill-mode work for both of those.
Currently line comments are auto-filled correctly:
-- abc abc abc abc abc abc abc abc abc abc abc abc…

Gracjan Polak
- 1,102
- 6
- 21
4
votes
1 answer
Can I make "comment-region" comment empty lines?
In LaTeX code I can have:
Lorem ipsum dolor sit amet, consectetur
\begin{comment}
adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
Ut enim ad minim veniam, quis nostrud exercitation
\end{comment}
ullamco laboris…

Gabriele
- 1,554
- 9
- 21
4
votes
1 answer
add a space after the comment delimiter
When I'm writing a comment and press M-j to continue the comment on the next line (using single-line comments), if I press it multiple times say because I want to leave the next comment line "empty" for separation, the cursor ends up appearing right…

Jorge Israel Peña
- 1,265
- 9
- 17
3
votes
2 answers
How to get emacs to automatically insert block comment prefixes?
I would like to type source code comments of the form:
{-
- Hello…

rityzmon
- 181
- 3
3
votes
2 answers
Is there a package for supporting two types of comments?
So, you would be able to setup it like this
(setq
one-line-comment "//"
multi-line-comment-start "/*"
multi-line-comment-end "*/")
And use one command to comment anything. If nothing is selected it would comment one line otherwise it would…

ais
- 225
- 1
- 7
2
votes
0 answers
What is (setq comment-style 'aligned) supposed to do?
First let me show a few things that work correctly. I am doing everything shown below using emacs -q foo.txt in a text buffer.
I make these settings first:
(setq comment-start "<<")
(setq comment-end ">>")
(setq comment-style 'box)
(setq…

Lone Learner
- 137
- 7
1
vote
1 answer
how to break apart text into lines of a specified max width
I am writing long, descriptive text above a line of code and would like to format it into comment lines of a specified max width, while not splitting text mid-word. How can I do this?
For example, I have written several paragraphs of comments above…

mark
- 293
- 1
- 9
0
votes
2 answers
How can I disable some code without commenting it out or removing it?
When I need to disable code without removing it, I comment it out. I find this clumsy, especially when the code is a function definition or some other kind of cohesive whole, such as:
(global-set-key "\C-x" 'do-stuff)
(defun do-stuff () ...)
Is…

Philippe-André Lorin
- 123
- 4
0
votes
1 answer
How to make comment-dwim comment from cursor position if its middle of the line?
I am using comment-dwim-line to comment out multiple lines. For this, I automatically move cursor always to the beginning of a line. I just want to use this behavior if the cursor is at beginning of a line or multiple line is selected.
If the cursor…

alper
- 1,370
- 1
- 13
- 35
0
votes
1 answer
How can I make this lisp function more general?
I've recently made this little function:
(defun luctins/rust-continue-comment ()
(interactive)
(if (nth 4 (syntax-ppss))
(let ((co (concat "\n"
(save-match-data
…

Luctins
- 120
- 7
0
votes
1 answer
IntelliJ style comment block cannot be recognized
In java-mode, I find the IntelliJ style comment block /** ... */ cannot be recognized correctly. And I have checked that the value of comment-start-skip variable (inherit from c-mode) is set as
"\\(//+\\|/\\*+\\)\\s *", which is supposed to match…

angeldsWang
- 111
- 6
0
votes
1 answer
How to uncomment multiple expressions in Lisp code?
I am using Emacs, Slime, Paredit, and other packages to work on Common Lisp (SBCL).
It is really useful to comment out multiple expressions while debugging.
For instance, suppose I have these placeholder expressions:
( ( )
(
((…

Pedro Delfino
- 1,489
- 3
- 16
0
votes
1 answer
Comment code using elisp
Input and desired output
Original code Commented out code:
C %% MODULE %% module_name C~ CPR C ## MODULE ## module_name
lines of code C~ CPR lines of code …

Prasanna
- 1,540
- 16
- 30
0
votes
0 answers
Custom comment with comment-line and comment-dwim
Basically, what I want to do is to customize comment-start and comment-end when invoking different commands to then call comment-dwim or comment-line with them.
What I managed to do so far is the following (thanks to…

Lhooq
- 230
- 3
- 10