Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

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.

5
votes
2answers
81 views

Is there an emacs command to go to end of code line (before line comment and whitespaces start)

say you have that: stuff indented stuff # commented stuff We already got move-beginning-of-line and back-to-indentation for the left side. Now, for the right side... I'd love to know if you ...
1
vote
1answer
33 views

How to prettify symbols inside comments?

I'm using prettify-symbol mode together with Pragmata Pro.el. Ligatures work perfectly fine in the source code but for some reason with comments they don't. I think I'm missing something since it's ...
1
vote
1answer
35 views

Emacs custom major mode with multiple comment types

I'm trying to write my first (very simple) major mode for Emacs. My goal is to have multiple comment types, but I can't find a way to implement this. Basically, I want my major mode to make ...
0
votes
0answers
20 views

unexpected long indent after colon in web-mode

I have some trouble locating the source of 8 tabs and 3 spaces more than the previous indentation when I'm inside js inside web-mode. These appear after a line that ends with a colon. Example (note ...
6
votes
1answer
84 views

How to prevent emacs from fontifying empty part of the line?

As an example, if I start a one line comment: ;; Comment⏎ Emacs will fontify the the whole line, from the beginning of line, occupying the entire width of the window, as comment. This can be made ...
2
votes
0answers
68 views

Strange comment indentation results

I am working with a simple major mode. The format has one single line comment delimiter, i.e., %. However, I get strange results when running fill-paragraph on a comment. Specifically, the result I ...
1
vote
0answers
33 views

EMACS doesn't grey out comments

When I comment out code with combination of /* and */ in JavaScript nothing happens with text and it stays the same color. (You can see it in second part of code, one that is not grayed out but is ...
1
vote
0answers
28 views

Enable `cc-mode` documentation highlightning per minor mode

I am writing a minor mode for enabling support for JML within Java files. I realized the syntax highlighting with cc-mode's support for documentation comments. It works if I set c-doc-comment-style ...
0
votes
0answers
22 views

fill style for block comments (lean-mode)

lean-mode (available on MELPA) defines two kinds of comments: -- like this and /- like this -/ I've noticed that when filling long lines, the behavior is sometimes not optimal. E.g., /- xxx ...
0
votes
1answer
45 views

align doesn't indent multiple lines of C code correctly

This is my simple C code block: int main() { // the enty function in x = 100; // my new variable for(int i=1; i<2012; ++i) { // loop a lot x -= i; } } /* ...
3
votes
2answers
183 views

How to align both of comments and macro of multiple lines with space instead tabs for C/C++ code?

This is my configuration in init.el for C/C++ code which is default value in linux kernel: (setq indent-tabs-mode t) I'm using this style and won't change it to nil. And indentation and alignment ...
1
vote
0answers
32 views

Move point to just before end of a comment

Given that the point is right in front of a comment, how do I move it to the end of the comment, but before the comment end markers? For example: for a C++ // xxx comment, I would like to move the ...
0
votes
1answer
78 views

Why does emacs put a black background on comments?

For some reason emacs shows comments on a black background. The image shows an example from my emacs with the otherwise amazing color theme "aalto-dark" from the color-theme-modern package. I don't ...
0
votes
1answer
61 views

Elisp-Function to always insert “*/” in C-Mode when “/*” was typed

I want to implement the functionality, that i wrote about in the title. Since searching the web for existing solutions didn't give me anything useful, i figured i would just try and implement it ...
1
vote
1answer
149 views

How to fold / collapse the first comment block on file load?

Is there a way to fold the first comment of a file on load? While I don't like code folding in general, it can be handy in this one instance when every file has a boiler plate header which isn't ...
6
votes
2answers
217 views

C++ mode: smartly use /*…*/ for comment-dwim

I want to adjust the behavior of comment-dwim when editing c++ files: When a region is selected that either starts or ends in the middle of a line I would prefer /* ... */ comments. For the other ...
1
vote
0answers
30 views

Font-locking for text inside org-mode COMMENT blocks

While other sorts of #+BEGIN ... #+END blocks seem to get font-locking applied to them (potentially changing foreground and background colours etc.), #+BEGIN_COMMENT ... #+END_COMMENT blocks do not. ...
1
vote
0answers
119 views

How to add additional comment syntax to a mode?

In general, given a major mode with a defined comment syntax, what do I have to define or change to add a new comment syntax? By "adding", I mean setting some new characters so that they work with ...
0
votes
1answer
49 views

Elisp: Inserting Comments

I'm trying to write an elisp program that will insert a section header and footer as a comment. For example, if I need a section called "intro" for my LaTeX document, the following would be inserted: ...
4
votes
6answers
169 views

Search for “foo bar” ignoring comments and newlines

How do I search for "foo bar" ignoring comments and newlines in emacs? For example, given the tex file fragment blah blah foo % comment 1 % comment 2 bar blah blah I'd like to be able to type "foo ...
3
votes
2answers
176 views

White space being inserted before a semicolon in asm-mode

When I try to insert a semicolon in my code (in asm-mode) it seems to indent a certain number of tabs like this (usually 4 it seems): D ; And if I put another semicolon on the next ...
2
votes
2answers
108 views

indentation (with multiline comments) in batch processing

i'm trying to indent a couple of C++-files (and untabify them; and remove trailing whitespace), so i thought about using emacs in batch mode. Since I'm pretty much a noob when it comes to elpa (or ...
2
votes
1answer
51 views

command to mark a block comment as region

Is there an existing EMACS command to select a block comment? That is, I have /** * A Comment */ I want to set the mark ahead of the /** and set the point after */. I realize there are several ...
1
vote
2answers
90 views

Hide only comments

In hs-mode, is there a way to only hide the comments (C-style, delimited by /* ...*/), and no other blocks of code? (there was nothing obvious in M-x customize-group hideshow)
1
vote
0answers
41 views

org-fill-paragraph leaves a comma at end of C style comment

In a src block when there is a C style comment /* ... */ doing an org-fill-paragraph would always put a comma just before the last star, like this: /* Some comment ,*/ Is there a way to stop it from ...
1
vote
1answer
245 views

Indenting within block comments in C-mode Emacs

After writing functions in C/C++, I like to format my block comments that explain a function's purpose, parameters, use, and so on. (See example below) However, to indent my comments in emacs, I ...
3
votes
1answer
97 views

disable strange comment behavior in AUCTeX

When I have a commented line in my TeX file, eg some text that is not commented |%% here is a comment followed by more uncommented text (the | represents point), and I hit RET, point is moved past ...
0
votes
0answers
79 views

How to change the command for comment toggling

spacemacs with Evil uses gcc to toggle whether a line is commented or not. I'd like to change it to ,cc. How should I go about this in my .spacemacs file?
1
vote
0answers
65 views

Doxygen style for c-doc-comment-style? [duplicate]

The option c-doc-comment-style supports javadoc, autodoc and gtkdoc. Is there a way to get doxygen support? (\returns, \note, \brief... etc)
2
votes
0answers
86 views

How to modify behavior of syntax highlighting without editing the original source?

There is a bug in C/C++ comment highlighting (bug 11865) Where the fix appears to be to modify the value of c-font-lock-doc-comments Is there a way to do this in my emacs config, instead of having ...
0
votes
0answers
172 views

How to toggle C/C++ multi-line comments using preprocessor `#if 0` … `#endif`?

Is it possible to configure C/C++ multi-line comments to comment/uncomment selected text using the preprocessor? eg: Before: // a comment Some(code); /* some comment */ After: #if 0 //...
1
vote
0answers
77 views

Keyword as comment ender (and starter)

In my previous question I asked about complex comment-start sequence and I think I figured it out, but now I have another problem. Let say we have this mode: (defconst test-font-lock-keywords '(("\\...
1
vote
1answer
69 views

Complex comment-start (and end) sequence

As far as I understand there is syntax flags only for comment delimiters made up of two characters but if I have comment delimiters of length greater than two characters is it possible to change ...
3
votes
1answer
137 views

How do I teach Emacs to re-wrap /* */ comments?

Is there an existing function, and if not how would I write one, that turns this: /* asdasdasd asdasdasd asdasdasd */ /* asdasdasd asdasdasd asdasdasd asdasdasd asdasdasd */ /* asdasdasd asdasdasd ...
0
votes
1answer
25 views

Shift text after cursor to specified column

If I have a line like: vec3 pos; // May not be defined. And I want to shift the comment to a specific column number, say 27, such that I get: vec3 pos; // May not be defined. Is ...
1
vote
0answers
48 views

auto-fill-mode fails in comment with empty second line

Consider the following comments: ;; This is the first line of a comment. ;; ;; This is the second line, which begins a paragraph. If I have ;;auto-fill-mode enabled, I lose the leading space! ;; ...
6
votes
3answers
422 views

Syntax highlighting for comments starting with specific sequence of characters

In clojure, the comment character is ;. clojure-mode syntax highlighting + color scheme greys comment text out. I want emacs to color lines that begin with ;-; with a different color. For example: ...
2
votes
0answers
79 views

How to set web-mode to use single-line comment style instead of multi-line for JavaScript

When commenting C-style code like C++, JavaScript etc., I use single-line comments to be able to uncomment a previously commented region selectively, i.e // This // is // a single-line style // ...
2
votes
0answers
60 views

How to protect LaTeX comment lines from indentation?

When I type <TAB> in a LaTeX file anywhere on a comment line, the comment symbol is moved to the beginning of the previous non-blank line. This also occurs with M-x indent-region. Is there a ...
4
votes
1answer
54 views

How to treat region between conflict markers as comment?

While resolving complex conflicts manually, I usually want emacs to treat conflict markers and region between them as comment, since it breaks major-mode's syntactic analysis (fontification, electric-...
2
votes
2answers
171 views

Is there a way to comment within a line in elisp?

Is it possible to comment the string "emacs" below while keeping this code one line? If so, how? (message "hi") "emacs" (message "hi!")
1
vote
1answer
36 views

How to auto prefix with comment char when inserting code ref label with org-store-link

There is a way to link to a specific link of code in org babel src block. with org-store-link. Here is an example: ;;; This is comment | line. | (describe-char | (point)) ; | comment | (message | ...
4
votes
2answers
594 views

How to get emacs to automatically insert block comment prefixes?

I would like to type source code comments of the form: {- ...
5
votes
1answer
141 views

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" ...
1
vote
3answers
88 views

If I am in a comment (including empty lines), how do I get to the beginning of the comment?

I have the following problem: I am in a comment or the empty lines after or within the comment. I want to get to the first line of the comment. So no matter where I am in this commented block, I ...
16
votes
1answer
771 views

Emacs Lisp comment conventions

The Emacs Lisp Reference Manual's Appendix D.7 mentions some comment tips: Single semicolons (;) should be used for inline comments. Double semicolons (;;) should be used for line comments. Triple ...
4
votes
1answer
387 views

how to define color for part of a comment?

How to make colored some part of comment? Let comment be ;; This is James Bond diary. And I want to make "James Bond" in green. There will be only a few such strings and no places where it will be ...
1
vote
0answers
24 views

Navigation ignores comment blocks in (La)TeX mode

I sometimes leave large blocks of comments in LaTeX source code: Text text text text. % Comments comments comments comments. % Six lines of comments. % More comments. % Separate comment block. % ...
1
vote
1answer
170 views

setting comment face in major mode on multi-line word-delimited comments

I am working on a major mode for an input file format I am interested in and want to set multi-line comments with the delimiters skip and noskip like skip larb noskip or skip GRID TYPE ...
6
votes
0answers
98 views

Code blocks in font-lock comments

I'm developing a major mode for a language that has doc comments. They look like this: (** Foos three bars. Better call this as [foo 1 b c]. Though of course [foo a b 1] works as well. **) ...