1

Complete emacs/lisp newbie trying to switch from vim.

I noticed that emacs indents C# files to 4 spaces, which is normally great, but I'm working on a project that requires 2 space indentation.

I've been searching and tried a few things, but it's not working for me. Here's my .spacemacs relevant sections:

(defun my-setup-indent (n)
  (message "Setting up indentation!")
  ;; java/c++
  (setq substatement-open 0)
  (setq c-basic-offset n)
  (c-set-offset 'substatement-open 0)
  (setq tab-width n)
  (setq indent-tabs-mode nil)
  ;; web dev
  (setq javascript-indent-level n)
  (setq js-indent-level n)
  (setq js2-basic-offset n)
  (setq web-mode-markup-indent-offset n) ; web-mode, html tag in html file
  (setq web-mode-css-indent-offset n) ; web-mode, css in html file
  (setq web-mode-code-indent-offset n) ; web-mode, js code in html file
  (setq css-indent-offset n) ; css-mode
  )

(defun dotspacemacs/user-init ()
  "Initialization function for user code.
It is called immediately after `dotspacemacs/init', before layer configuration
executes.
 This function is mostly useful for variables that need to be set
before packages are loaded. If you are unsure, you should try in setting them in
`dotspacemacs/user-config' first."
  )

(defun dotspacemacs/user-config ()
  "Configuration function for user code.
This function is called at the very end of Spacemacs initialization after
layers configuration.
This is the place where most of your configurations should be done. Unless it is
explicitly specified that a variable should be set before a package is loaded,
you should place your code here."
  (global-linum-mode) ; Show line numbers by default
  (my-setup-indent 2) ; indent 2 spaces width
  )

;; Do not write anything past this comment. This is where Emacs will

The only csharp "layer" I have added is csharp.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.