Skip to main content

Questions tagged [comment]

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.

Filter by
Sorted by
Tagged with
0 votes
0 answers
4 views

comment-dwim inserting leading spaces in prog-mode

I started using yasnippet today, and was surprised with this buffer when using yas-new-snippet: # -*- mode: snippet -*- # name: # key: # -- I could see there was nothing unusual ...
dmvianna's user avatar
  • 392
0 votes
1 answer
34 views

Does Emacs support stripping comments in CLI mode?

While researching how to remove C and C++ style comments from a file, I stumbled on the following two comments by Alan Mackenzie from almost 20 years ago: I can assure you, as half of the Emacs CC ...
Gao's user avatar
  • 101
0 votes
1 answer
57 views

How do I disable the annoying garbling of multiline comments in Common Lisp

In Common Lisp you can define multiline comments with #| \n\n\n |#. However when I press Return with cursor above such comment, each line of the comment is appended with ' ;' and pressing Return ...
ruby_object's user avatar
-1 votes
1 answer
48 views

Shouldn't `comment-region`/`uncomment-region` preserve TABs?

As Perl isn't very smart indicating where the actual syntax error is (especially when a semicolon or a closing parenthesis is missing), I had commented larger parts of the added code, just to help ...
U. Windl's user avatar
  • 213
0 votes
0 answers
39 views

Different styles of comments in emacs mode

I'm working on the integrating Proof General(PG) into a proof assistant, but I have difficulty in configuration of comments. I have different settings for single-line comments and multi-line comments ...
phdstudent's user avatar
0 votes
2 answers
124 views

Comment or uncomment a single line in Emacs

I'd like to have an emacs-lisp function that comments or uncomments the line the cursor is on. At the very least, it needs to work in latex-mode and emacs-lisp-mode, as well as in org-mode inside ...
Addlai's user avatar
  • 141
1 vote
1 answer
42 views

How to apply different whitespace settings for different buffer portions?

Does the minor mode whitespace library provide any way to apply different settings to different portions of the same buffer? For example, I might like to highlight `TAB characters in a comment block, ...
RoUS's user avatar
  • 121
2 votes
1 answer
333 views

How to comment from the start of the line in makefile-mode?

If one highlights a tab-indented line in makefile-mode and runs a comment function (eg. comment-dwim, comment-line, comment-region, etc.), the comment symbol (#) is inserted after the initial tab, ...
Ian Mackinnon's user avatar
0 votes
1 answer
32 views

Define new comment style with string literals rather than characters

I am trying to define another comment style, similar to what we can do with modify-syntax-entry: (modify-syntax-entry ?/ ". 124b") (modify-syntax-entry ?* ". 23") (modify-syntax-...
Jake Ireland's user avatar
2 votes
2 answers
113 views

Using different line length for comment blocks

I am setting the fill column (80) to specify the maximum width of a line before it should be automatically wrapped or broken into multiple lines. Although this setting is useful for ensuring ...
Dilna's user avatar
  • 1
1 vote
1 answer
81 views

How can a region matched by "string-match" be commented out with "comment-region"?

I have this code: (when (string-match "^[ ]*\\\\usepackage{url}" (buffer-string)) (comment-region (match-beginning 0) (match-end 0))) I tested it on these lines: %% LaTeX file test The ...
Onner Irotsab's user avatar
2 votes
0 answers
40 views

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 "<<") (...
Lone Learner's user avatar
2 votes
1 answer
49 views

Why the number of spaces inserted by M-; is less than the number of spaces in comment-start and comment-padding?

I am using emacs -q and editing a text buffer foo.txt. I have added the following settings: (setq comment-start ">::") (setq comment-padding ":::<") Now if I select a region ...
Lone Learner's user avatar
0 votes
2 answers
279 views

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 &...
Philippe-André Lorin's user avatar
1 vote
2 answers
64 views

How to Organize Comments into a Grid on Emacs?

I see this done a lot. Don't know what it's called. Don't know how to do it. See how the comments are all lined up? int myNum = 5; // Integer (whole number) float myFloatNum = 5.99f; /...
Matthaeus Gaius Caesar's user avatar
0 votes
1 answer
61 views

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 ...
alper's user avatar
  • 1,460
0 votes
1 answer
34 views

Colouring different parts of a comment

I want to change the colour of substrings inside comments in a buffer. So that text enclosed by braces are coloured differently. For the following bash comment, I want the text enclosed bf {} to be ...
Dilna's user avatar
  • 1
3 votes
1 answer
68 views

Can you mark the end of 'compilation' in an eLisp source file?

In all of my source files, in whatever language, I use some trick or other to end compilation and then add a documentation trailer in perldoc format from which I can generate a man page. I always keep ...
Dale Amon's user avatar
0 votes
1 answer
51 views

Using general comment character used in programming languages

I am using highlight-regexp with a regexp pattern that includes the elisp comment characters ;;. How can I extend the pattern so that it adequately handle the general comment character for each ...
Dilna's user avatar
  • 1
1 vote
1 answer
93 views

Using a sub-expression for `highlight-regexp`

I have made a face to highlight elisp comments starting with ;; [ using hi-lock. My intention is to only colour the expression [text] using SUBEXP. (highlight-regexp "^;; \\[.+\\].+$" 'face-...
Dilna's user avatar
  • 1
0 votes
0 answers
38 views

Keeping specific comments with bold weight

I am using a bold typeface, but for comments I am using normal weight. But I would like that some specific comments to remain displayed with bold weight. The specific comments are those that start ...
Dilna's user avatar
  • 1
2 votes
1 answer
218 views

How to make comment-dwim comment out the current line when there is no active region?

This question is about changing the behavior of comment-dwim when no active region is defined. The current behavior is defined below (from C-h k), which is kind of complicated and not what doing what ...
tinlyx's user avatar
  • 1,384
0 votes
1 answer
48 views

How can I make this lisp function more general? [closed]

I've recently made this little function: (defun luctins/rust-continue-comment () (interactive) (if (nth 4 (syntax-ppss)) (let ((co (concat "\n" (...
Luctins's user avatar
  • 120
1 vote
1 answer
332 views

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 ...
mark's user avatar
  • 293
0 votes
1 answer
492 views

How to comment out multiple or all files in a directory?

I frequently use commands like paredit-comment-dwim, comment-dwim, and comment-region. I am also aware these commands can have a compound effect with the mark command. But, I would like to comment ...
Pedro Delfino's user avatar
0 votes
0 answers
88 views

ess font-lock-add-keywords not working

For several years I have been using this bit of code in my init.el file to organize comments. Here is the code ` (defgroup ess-jb-faces nil "Faces used by cutomized ess-mode" :group '...
Jacob's user avatar
  • 21
2 votes
2 answers
336 views

keep org-mode comments on export

I am drafting a document in org. Because I will have some coauthors, I will have to switch to LaTeX at some point. I am usually putting a very short description of the paragraph on top: # why do we ...
gdkrmr's user avatar
  • 215
1 vote
1 answer
275 views

Comment continuation in block comments

It used to work in c-mode, but I cannot get it back, and now I miss it in rustic, too: If in a block comment, I want Emacs to insert "\n * " after I hit return: /** *<-- [if I hit return ...
Markus's user avatar
  • 111
1 vote
2 answers
117 views

How to execute Elisp code embedded in c++ comment?

While I found lots of sources, how to use Elisp in an org-mode document, what I try to do is not related to org-mode at all. My idea is to embed Elisp functions and calls of Elisp functions within ...
BitTickler's user avatar
0 votes
1 answer
274 views

To remove characters in the beginnings of lines

To add // in the beginnings of multiple lines I can use either string-insert-rectangle or string-rectangle (C-x r t). But how is it possible to remove these characters instead? This question is not ...
john c. j.'s user avatar
0 votes
1 answer
126 views

Adjust how comments work in markdown-mode

How can I adjust how M-; (comment-dwim) works in markdown-mode? Specifically, I'd like for it to not use delimiters for each line. As an example, in Markdown mode, if I commend a line like This is a ...
asmeurer's user avatar
  • 1,612
0 votes
1 answer
106 views

Comments in org capture templates

I have a lot of org capture templates defined in my .emacs file. I'd like to be able to add a "comment" into some of them - how would I do that? For example when I'm capturing a new GTD ...
Johan's user avatar
  • 345
1 vote
1 answer
52 views

How do I match comments where the start and the end character are the same?

I have a programming language I want to make a major mode for where both the start and the end characters of a comment are the same. Specifically #. # This is a comment # As you can see it can match ...
irishgreencitrus's user avatar
1 vote
1 answer
192 views

No comment syntax defined when tangling lua or vimrc code blocks

Resolution With help from commenters, I have things kind of working. I removed :comments link from Properties. I manually added comments to the top of every code block to replicate what :comments ...
Jason's user avatar
  • 111
0 votes
0 answers
163 views

Inheritance of font-lock-comment-delimiter-face

How does inheritance of font-lock-comment-delimiter-face work with font-lock-comment-face? The following uses a different colour for the comment delimiter by setting the foreground colour to font-lock-...
Dilna's user avatar
  • 1
1 vote
0 answers
135 views

How to properly use modify-syntax-entry flags to syntax highlight comments in Lua?

I made my own Lua major mode about a month back. There is one thing that is still not working: highlighting comments. At first, I simply added ("--.*" . font-lock-comment-face) to lua-font-...
Alan's user avatar
  • 37
2 votes
1 answer
210 views

How to hide comments and move them to a separate window?

I'm interested in hiding comments in code or structured text, but displaying them in another window; i.e. same buffer, two windows side-by-side, one showing the main text (code, or content), but ...
Jacob Lee's user avatar
  • 237
3 votes
1 answer
35 views

Is it possible for hideshow to display both the start and trailing comment characters?

Running hs-toggle-hiding converts a C-style multi-line comment from. /* * This is a comment. */ To: /* ... Is there a way to collepse the comment to: /* ... */ Instead?
ideasman42's user avatar
  • 9,157
0 votes
1 answer
158 views

Docstring - quotes or semicolons?

In the documentation I only see mention of using semicolons for comments and docstrings, but in elisp-documents I regularly see functions documented in double-quotes, such as in org.el: (defun org-...
xeruf's user avatar
  • 354
0 votes
1 answer
46 views

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 "\...
angeldsWang's user avatar
1 vote
1 answer
64 views

How to update beg end with comment-region

Scenario: I have Emacs open with split window. Top window contains an R script. Bottom windows has the interactive R session. I want to be able to copy a region from the interactive window to the ...
Kevin Wright's user avatar
1 vote
1 answer
125 views

After setting syntax-propertize-function, comment is not being fontified with comment face

I'm trying to build a major mode for xwiki, where I'm defining {{{ verbatim }}} as a comment. So far, I've done (eval-when-compile (defconst xwiki-syntax-propertize-rules (syntax-...
ackerleytng's user avatar
4 votes
4 answers
5k views

How can I create block (multiline) comments in Lisp code?

How can I do multiline / block comments in Lisp code - e.g. in the init.el. In Python I would do it like this """Block comment """ In C/C++ like this /* Block comment */ ...
buhtz's user avatar
  • 749
0 votes
1 answer
186 views

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 ...
Pedro Delfino's user avatar
0 votes
1 answer
168 views

Why Emacs creates multiples whitespaces after I create a comment and jump to a new line?

I am using Emacs, Paredit, Slime to work on Common Lisp (SBCL). When I create a comment such as: ; test It is placed as expected. But if I press return in order to create a new line below ;test this ...
Pedro Delfino's user avatar
0 votes
1 answer
49 views

Auctex change default comment style for latex-mode

I want a double %% to start my comments in latex documents. I'have found two solutions suggested ;; solution 1 (add-hook 'latex-mode-hook '(lambda() (setq comment-start "%% "))) ;; ...
PinkCollins's user avatar
0 votes
2 answers
175 views

Commenting moves point unexpectedly

The usual behavior of comment-line is to move point to the next line. When commenting code within an Org source block, however, the point will jump to some previous line. For example, say that point ...
Lorem Ipsum's user avatar
  • 4,577
0 votes
1 answer
49 views

How add specifc string(ex: TODO) along with a comment character for a specifc mode?

Based on specific mode, by using a keybinding I want to add a TODO string that is preceded by an unique comment character. For example, (org-mode is exception since ** does not stands for comment and ...
alper's user avatar
  • 1,460
4 votes
1 answer
236 views

How to convert single line comments to multiline comments?

I have a bunch of single line comment blocks in C-code that I want to change to multiline. Example: // foo // bar should become: /* foo * bar */ How can I do this easily in Emacs?
Arne's user avatar
  • 419
0 votes
0 answers
122 views

Uncommenting not working on Javascript file

I am trying to use the block un-comment command C-x C-; but I am getting the error message "Can't find the comment end". I am writing Javascript code in an .html file. The block comment ...
Lucas Myers's user avatar