Getting emacs M-; to produce // style comments
How do I change the style of comments for M-; (comment-dwim) when using c-mode?
I would like it to use 开发者_如何学JAVAcomments preceeded by // instead of /* */ nesting.
Version:
GNU Emacs 23.2.1 (x86_64-pc-linux-gnu, GTK+ Version 2.20.1) of 2010-12-11 on brahms, modified by Debian
The relevant vars are comment-start
and comment-end
so you can use this:
(add-hook 'c-mode-hook (lambda () (setq comment-start "//"
comment-end "")))
From http://www.cs.cmu.edu/cgi-bin/info2www?(emacs)C%20Mode:
C++ mode is like C mode, except that it understands C++ comment syntax and certain other differences between C and C++. It also has a command `M-x fill-c++-comment', which fills a paragraph made of C++ comment lines.
So you can just add this line to your .emacs:
(add-to-list 'auto-mode-alist '("\\.[ch]\\'" . c++-mode))
精彩评论