How to decrease TAB size in Sublime Text 3

Asked

Viewed 1,259 times

1

I edit HTML files with CSS and JS using Sublime Text 3. To reset to Sublime Text 3, use shortcut Ctrl+shift+r when pasting a code from the outside. What is the best practice to automate the tab key decreasing tabs from 4 spaces to 2, for example?

  • Give a find and replace ...

  • Replace? Could you detail your idea, please?. If the idea is "paste again", we have Ctrl+shift+v to paste and indent.

  • I put in the reply

  • I saw your reply @thxmxx when I pasted your configuration I got this error alert: Error trying to Settings: trailing in Packages User Preferences-sublime-Settings:8:1 Where, 8 is the line number and 1 is the position of the { Preferences-sublime-Settings, as at the beginning or end of the file. I was unsuccessful even observing the saved file: Preferences.sublime-Settings So I looked up the menu View, Indentation, Tab Width:2 and had the expected result.

1 answer

1

To set the default, go to Preferences -> Settings - Default/User and use the following configuration:

{
  "tab_size": 2,
  "translate_tabs_to_spaces": true,
  "detect_indentation": false
}

Edit: After defining Preferences -> Settings - Default/User, select all text go to Edit -> Line -> Reindent

If you want to add a shortcut to this action go to Preferences → Keybindings and add

[
    { "keys": ["f12"], "command": "reindent", "args": {"single_line": false}}
]

So just sell the whole text and press F12.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.