Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Set .h to c++-mode group in emacs [duplicate]

Tags:

c++

emacs

I'm not entirely sure if this question belongs on stackoverflow or superuser (is there an emacs stack exchange?). Based on the meta.stackoverflow post I'll assume that it does.

My emacs defaults header files (of the .h variety) to c mode. I can easily type M-x c++-mode and get my highlighting back, but because I program more often in c++ than c. I was wondering what I needed to change to add .h to the c++ group.

like image 835
JSchlather Avatar asked Dec 28 '22 08:12

JSchlather


1 Answers

Here's what I have in my .emacs file:

; Make .h files be C++ mode
(setq auto-mode-alist(cons '("\\.h$"   . c++-mode)  auto-mode-alist))

There might be an easier way, but this works.

like image 186
Ron Romero Avatar answered Jan 05 '23 06:01

Ron Romero