0

I am new to emacs and have a C file which is presently in gnu style in cc-mode. I have changed the style to linux by making the necessary changes in the .emacs file.

I want to change the style of whole file (the prewritten code) to the style linux. I am unable to do so.

I have tried reindenting the entire file, but it is not working. (although, the code I add after setting the style does come in linux style)

Here is the code which I added in .emacs file to change the style to linux.

(setq c-default-style "linux"
      c-basic-offset 4)
Pratik Singhal
  • 6,283
  • 10
  • 55
  • 97

1 Answers1

1

Perform these steps:

  1. Go to the top of the buffer via (beginning-of-buffer), typically bound to M-<.
  2. Go to the very bottom of the buffer via (end-of-buffer), typically bound to M->. This sets a mark at the top of the buffer, then moves to the bottom.
  3. Execute the indent-region function, typically bound to C-M-\.

The final step will indent the region, which will be the entire buffer.

Steve Vinoski
  • 19,847
  • 3
  • 31
  • 46
  • Alternatively, `mark-whole-buffer` (`C-x h` by default) and then `indent-region` (step 3 in this answer). – ChrisGPT was on strike Mar 01 '15 at 15:37
  • @ps06756 are there any customization settings in the file that are keeping the style set to `gnu` or are setting different indentation levels? If you use `C-h v` to get the value of `c-default-style` and again to get the value of `c-basic-offset` when in that buffer, what values do you see? What style does the mode line for that buffer indicate? – Steve Vinoski Mar 01 '15 at 16:57