TabToSpaceConverter
Convert tabs to spaces in Sublime Text and preserve inline alignments.
Details
Installs
- Total 877
- Win 455
- Mac 237
- Linux 185
Sep 19 | Sep 18 | Sep 17 | Sep 16 | Sep 15 | Sep 14 | Sep 13 | Sep 12 | Sep 11 | Sep 10 | Sep 9 | Sep 8 | Sep 7 | Sep 6 | Sep 5 | Sep 4 | Sep 3 | Sep 2 | Sep 1 | Aug 31 | Aug 30 | Aug 29 | Aug 28 | Aug 27 | Aug 26 | Aug 25 | Aug 24 | Aug 23 | Aug 22 | Aug 21 | Aug 20 | Aug 19 | Aug 18 | Aug 17 | Aug 16 | Aug 15 | Aug 14 | Aug 13 | Aug 12 | Aug 11 | Aug 10 | Aug 9 | Aug 8 | Aug 7 | Aug 6 | Aug 5 | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Windows | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
Mac | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 1 | 1 | 1 |
Linux | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
Readme
- Source
- raw.githubusercontent.com
TabToSpaceConverter
TabToSpaceConverter is a Sublime Text plugin that converts tab characters in a file to spaces and applies your new tab width setting to it; while preserving tab based inline alignments.
Batch converting is supported.
Overview
The Problem
Let's say you have a file that uses hard tabs for indendation and for inline alignment:
And the above file is created with tab_size = 8
setting, so the inline alignment
only works when the tab_size
is 8
.
And then you want to adapt the file to a different styleguide, which uses 4 spaces for indentation. When you open the file with the new settings, you will see:
To apply the new styleguide to the file, you would normally use the Sublime Text menu in the status bar (Convert Indentation to Spaces):
Which would give you the below result, breaking the inline alignment:
The Solution
Use this plugin and get the below result, as you would expect:
Installation
You can install the plugin via:
- Package Manager by searching
TabToSpaceConverter
git clone https://github.com/maliayas/SublimeText_TabToSpaceConverter.git TabToSpaceConverter
- Downloading the zip of the repo and extracting into
Packages/TabToSpaceConverter
The plugin is developed for Sublime Text 3 and above. It's not tested on Sublime Text 2; however it may still work there, so you can give it a try if you have to.
Usage
This plugin is meant to be used with a keybinding. It's not defined by default,
because it needs some configuration. You should click the Preferences > Key Bindings
menu and then add a keybinding like this:
{
"keys" : ["ctrl+alt+t"],
"command" : "tab_to_space_converter",
"args" : {"previous_tab_size": 8, "all_views": false}
}
previous_tab_size
: In order the plugin to preserve inline alignments, it has to know whattab_size
setting was used when the file was created.all_views
: If you set this totrue
, all the open views will be converted. To save all those files, you can use theFile > Save All
menu.
You don't have to provide your current tab_size
setting to the plugin, just set it
in the Sublime Text and the plugin will read it.
Similar Plugins
Other plugins that are similar to this one (they don't do the same task though):
License
TabToSpaceConverter is released under the MIT License.