swift-emacs / swift-mode

Emacs support for Apple's Swift programming language.
GNU General Public License v3.0
370 stars 47 forks source link

[HELP-NEEDED] When set tab-width to 2, it is still not correctly indented with 2 space #136

Closed nuynait closed 7 years ago

nuynait commented 7 years ago

I don't know if it is a emacs config problem, but I have set the tab width to 2

image

Now when I write a function in swift

image

It is still taking 4 space of indentation.

I did research and seems that tab-width is everything we need to set to change indentation to 2 chars.

Am I miss anything here? Please any help is appreciated. Thanks.

alanshutko commented 7 years ago

There's a key hint in the documentation above:

NOTE: This controls the display width of a TAB character, and not the size of an indentation step.

You should instead set

swift-mode:basic-offset is a variable defined in ‘swift-mode-indent.el’.
Its value is 4

  This variable is safe as a file local variable if its value
  satisfies the predicate ‘integerp’.

Documentation:
Amount of indentation for block contents.

You can customize this variable.

[back]
nuynait commented 7 years ago

OH, it works. Thanks a lot.