Use semantic indentation with tabs and spaces during editing and spaces-only on disk
Visual smart tabs mode
Use semantic indentation with tabs and spaces during editing and spaces-only on disk.
This package is an extension to the semantic indentation package smart-tabs-mode package. It allows to use smart-tabs-mode when editing a file while still using spaces-only indentation when storing a file on disk.
smart-tabs-mode uses tabs for indentation and spaces for alignment, which allows to adjust the indentation width to your personal preference without changing the files. However, many projects have strong conventions, which do not allow to use tabs for indentation. Here smart-tabs-mode cannot be used, because the stored files will contain tabs. This is where visual-smart-tabs can help.
visual-smart-tabs replaces indentation spaces by tabs (using smart-tabs-mode) when a file is loaded and replaces the indentation tabs by spaces again when the file is stored on disk. Given that the indentation is consistent, this transformation happens seamlessly in both directions.
You need to enable smart-tabs-mode if you want to use visual-smart-tabs-mode. visual-smart-tabs-mode must be enabled after smart-tabs-mode in a buffer using it. This is because smart-tabs-mode must have been initialized properly for visual-smart-tabs-mode to work. The following code should work for a ruby files:
(add-hook 'ruby-mode-hook 'visual-smart-tabs-mode t)
Note that the third parameter t causes visual-smart-tabs-mode to be placed after all other hooks, in particular after the hook starting smart-tabs-mode.