Domanda

I changed the coding style to BSD on emacs and now it look like this:

switch(a)
{
 case TYPEvar:
    return x(node);
}

I want to add a tab before case, like this:

switch(node->type)
{
  case TYPEvar:
       return walk(node);
}

What do I need change in .emacs? I tried (I don't do emacs lisp) change tab-width in:

(setq-default c-basic-offset 2
          tab-width 2
          indent-tabs-mode t)

But it changed nothing.

È stato utile?

Soluzione

To do this only for the current buffer go to the line containing case and do C-cC-o, it will prompt you for syntactic symbol whose indentation you want to change enter/select case-label (this is selected by default). Then enter the value of indentation, enter your desired indentation.

The above sets the indentation for the current buffer. To set indentation for all the buffers you can use c-mode-common-hook as follows

(add-hook 'c-mode-common-hook (lambda ()
                                (add-to-list 'c-offsets-alist '(case-label . 2))))
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top