After installing a new kubuntu (16.04) and emacs (25.2.2) I have had indentation problems. It seems like indentation default values have changed or maybe I am missing some configuration file? Unfortunately, I don't know which version of emacs I had in my previous kubuntu 14.04, where everything was still fine (like the past 25 years in different unix and linux environments).

I don't know lisp and I have never before needed to customize emacs, but I have looked at instructions and managed to fix some problems by editing .emacs. Now I would like to set the tabulator size to 2 in the awk mode. (In C mode it is 2 by default as I wish.)

I tried to add the following to my .emacs:

;;set awk tabulator size
(add-hook 'awk-mode-hook
(lambda () (setq indent-tabs-mode t) (setq tab-width 2) (setq awk-indent-offset 2)))

but it has no effect. This was modified from an example how to set the tabulator size for python mode.

Do you know what is wrong here? Or is there some other place where to modify the awk mode?

1 Answer 1


Try using c-basic-offset instead of awk-indent-offset. It is automatically buffer-local so should not affect c-mode or others.

Complete answer, incl. avoiding tab characters:

(add-hook 'awk-mode-hook
  (lambda () 
    (setq indent-tabs-mode nil) 
    (setq tab-width 2)
    (setq c-basic-offset 2)))

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.