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.

Useful Links:

141 questions
22
votes
1 answer

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 semicolons (;;;) should be used for "comments which…
Tianxiang Xiong
  • 3,848
  • 16
  • 27
20
votes
1 answer

How to automatically create neat C comment blocks while typing?

Some code editors such as eclipse automatically form neat blocks when you start typing a multi-line comment: Is there some package or another way to do this in emacs too? Edit: To clarify: I do not want a key-combination that inserts a comment…
Geier
  • 692
  • 5
  • 15
19
votes
2 answers

Is there fully-automatic fill-paragraph-mode for code comments?

I'm looking for a minor mode to keep paragraphs filled at all times while typing (similar to what aggressive-indent-mode does for indentation). It also needs to be smart enough to only fill comments (and maybe strings depending on the…
dshepherd
  • 1,281
  • 6
  • 18
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,689
  • 4
  • 38
  • 84
13
votes
1 answer

How to change comment string used by comment-region?

Emacs generally comments regions well, but sometimes I wish I could change the string it prepends to lines. For example, in LaTeX, I would like to have a commented region only use a single % per line instead of two, i.e., % First line of commented…
karlo
  • 231
  • 2
  • 4
13
votes
2 answers

Function to delete all comments from a buffer, without moving them to kill ring

I need to be able to remove all comments from a buffer from elisp code. For now, I am using: (goto-char (point-min)) (comment-kill (count-lines (point-min) (point-max))) However, comment-kill is an interactive function, and its primary usage is to…
T. Verron
  • 4,233
  • 1
  • 22
  • 55
12
votes
3 answers

How can I detect if the current character is a comment character for that major mode?

I am working on this little function that pulls up the next line to the current line. I want to add a functionality so that if the current line is a line comment and the next line is also a line comment, then the comment characters are removed after…
Kaushal Modi
  • 25,203
  • 3
  • 74
  • 179
9
votes
3 answers

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: ;; This is a normal greyed out comment, we use ;;…
deadghost
  • 807
  • 1
  • 7
  • 13
9
votes
1 answer

How comment out a variable line in a local variable list

In a python file I have # Local Variables: # python-shell-interpreter: "python3" # python-shell-virtualenv-path: "~/.virtualenvs/datascience" # leo-python-args-to-send: "-f fqanalysis.txt" # End: For a couple of days I want to use the python file…
halloleo
  • 1,215
  • 9
  • 23
9
votes
2 answers

Commented lines shoot off to column 32 in octave-mode

I am using the octave major mode for editing my MATLAB code, since it is more convenient than the unsupported MATLAB packages for emacs on the internet. One downside is whenever I try to auto-indent commented lines, the comment character is carried…
osolmaz
  • 435
  • 3
  • 13
9
votes
1 answer

Hide comment in current buffer

Is their a way to hide comment whatever the language used? Like if I'm in cpp mode all /* ... */ should be hide and if I'm on LaTeX mode, all % ... will be hide.
Romain Picot
  • 193
  • 1
  • 6
9
votes
2 answers

How to change comment character from # (hash) to % (percent sign) for Octave major mode

By default, comment-region inserts # for comments in Octave major mode: # foo I want to modify the behavior so that it inserts the percent sign % foo I used the following (setq octave-mode-hook (lambda () (setq octave-comment-char ?%)…
osolmaz
  • 435
  • 3
  • 13
7
votes
1 answer

Modify org-mode's definition of comment lines?

Q: how do I change org-mode's definition of a commented line? According to the manual, org-mode comments work as follows: Lines starting with zero or more whitespace characters followed by one '#' and a whitespace are treated as comments and will…
Dan
  • 32,584
  • 6
  • 98
  • 168
7
votes
4 answers

How do I disable ffap (find file at point) when the first two non-space characters in a line are '//'?

In Verilog/C/C++, comments can begin with //. Here's an example comment, //This is a comment I like to use the find-file-at-point feature. If my cursor is on the file name in `include "some_file.v". But if my cursor is on the above example…
Kaushal Modi
  • 25,203
  • 3
  • 74
  • 179
6
votes
1 answer

How to implement comments outline in ESS similar to that of Rstudio?

Shifting from Rstudio to ESS took some time with me because of the steep learning curve of a versatile Emacs editor, but is was a worthwhile experience. What I am still missing in ESS is that outline or overview of the R script file based on…
doctorate
  • 1,789
  • 16
  • 39
1
2 3
9 10