I know there are a lot of posts about this, but I couldn´t get it to work.
I use tabs for coding. Is there a way, to convert always spaces to tabs? I.e. on open and on S
You can use the command palette to solve this issue.
Step 1: Ctrl + Shift + P
(to activate the command palette)
Step 2: Type "Indentation", Choose "Indentation: Convert to Tabs"
if you have Mac just use help option (usually the last option on Mac's menu bar) then type: "tab indentation" and choose a tab indentation width
but generally, you can follow this path: view -> indentation
As you might already know, you can customize your indention settings in Preferences.sublime-settings
, for example:
"detect_indentation": true,
"tab_size": 4,
"translate_tabs_to_spaces": false
This will set your editor to use tabs that are 4 spaces wide and will override the default behavior that causes Sublime to match the indention of whatever file you're editing. With these settings, re-indenting the file will cause any spaces to be replaced with tabs.
As far as automatically re-indenting when opening a file, that's not quite as easy (but probably isn't a great idea since whitespace changes wreak havoc on file diffs). What might be a better course of action: you can map a shortcut for re-indention and just trigger that when you open a new file that needs fixing.
At the bottom of the Sublime window, you'll see something representing your tab/space setting.
You'll then get a dropdown with a bunch of options. The options you care about are:
Apply your desired setting to the entire document.
Hope this helps.
Use the following command to get it solved :
autopep8 -i <filename>.py