Difference between revisions of "Template:NewPage"
Jump to navigation
Jump to search
Line 1: | Line 1: | ||
− | '''{{{ | + | '''c-mode''' is the default [[major mode]] for editing [[C]] source files |
+ | ({{File|.c}} and {{File|.h}} files). It uses {{ModeLink|cc-mode}}. | ||
<!-----DONT REMOVE ANYTHING FROM THIS TEMPLATE ------------------------------> | <!-----DONT REMOVE ANYTHING FROM THIS TEMPLATE ------------------------------> | ||
Line 12: | Line 13: | ||
= Basic setup = | = Basic setup = | ||
− | + | c-mode is bundled with Emacs by default. No additional setup is required. | |
= Helpful keybindings = | = Helpful keybindings = | ||
− | ; {{Keys|C- | + | ; {{Keys|C-M-a}} |
− | : | + | : Go to the beginning of the current function. If you are between 2 functions, go the start of the previous one. |
− | ; {{ | + | ; {{Keys|C-M-e}} |
− | : | + | : Go to the end of the current function. If you are between 2 functions, go to the end of the next one. |
<!-------------------------------------------------------------------------> | <!-------------------------------------------------------------------------> | ||
Line 26: | Line 27: | ||
<!-- Customization common to all platforms goes here --> | <!-- Customization common to all platforms goes here --> | ||
− | == | + | == Change default indenting style == |
<source lang="lisp"> | <source lang="lisp"> | ||
− | ( | + | ; set k&r style |
+ | (setq c-set-style "k&r") | ||
+ | ; indent with 4 spaces | ||
+ | (setq c-basic-offset 4) | ||
</source> | </source> | ||
Line 63: | Line 67: | ||
= [[Emacs-23]] = | = [[Emacs-23]] = | ||
<!-- Customization/Notes specific to Emacs-22 --> | <!-- Customization/Notes specific to Emacs-22 --> | ||
− | + | ||
<!-------------------------------------------------------------------------> | <!-------------------------------------------------------------------------> | ||
Line 69: | Line 73: | ||
= Recommended Reading = | = Recommended Reading = | ||
<!-- Only internal links. DO NOT insert EXTERNAL LINKS --> | <!-- Only internal links. DO NOT insert EXTERNAL LINKS --> | ||
− | |||
− | |||
<!-------------------------------------------------------------------------> | <!-------------------------------------------------------------------------> | ||
= Project Pages = | = Project Pages = | ||
− | * [http:// | + | * [http://cc-mode.sourceforge.net/ cc-mode] |
− | |||
<!-------------------------------------------------------------------------> | <!-------------------------------------------------------------------------> | ||
= Tutorial Pages = | = Tutorial Pages = | ||
− | ;[http://wiki.bazaar.canonical.com/EmacsTips Emacs as commit message editor] | + | <!-- ;[http://wiki.bazaar.canonical.com/EmacsTips Emacs as commit message editor] --> |
− | :Tips for setting up Emacs as Bazaar commit editor. | + | <!-- :Tips for setting up Emacs as Bazaar commit editor. --> |
<!-------------------------------------------------------------------------> | <!-------------------------------------------------------------------------> | ||
<!-- Add categories based on user-level (beginner etc), user-role (programming, emacs contributor etc), platform (windows, linux etc) or work flow (text editing, document authoring etc) --> | <!-- Add categories based on user-level (beginner etc), user-role (programming, emacs contributor etc), platform (windows, linux etc) or work flow (text editing, document authoring etc) --> | ||
− | [[Category: | + | [[Category:Programming]] |
Revision as of 11:10, 31 March 2012
c-mode is the default major mode for editing C source files (.c and .h files). It uses cc-mode.
Basic setup
c-mode is bundled with Emacs by default. No additional setup is required.
Helpful keybindings
- [C-M-a]
- Go to the beginning of the current function. If you are between 2 functions, go the start of the previous one.
- [C-M-e]
- Go to the end of the current function. If you are between 2 functions, go to the end of the next one.
Common Customization
Change default indenting style
; set k&r style
(setq c-set-style "k&r")
; indent with 4 spaces
(setq c-basic-offset 4)
GNU/Linux
OS X
Windows
Emacs-24
Emacs-23
Recommended Reading
Project Pages