Chad Burkins
Chad Burkins

Reputation: 155

sublime text 2 reindent single-line true vs false

I'm new to sublime text 2, and would like to figure out how to reindent my code properly.

There's certainly the menu item: Edit->Line->Reindent, but I would like to have a keyboard shortcut.

I read this thread: Sublime Text 2: Auto fix indentation for javascript?

Helpful, so I've setup the following two shortcuts:

[
{ "keys": ["f5"], "command": "reindent", "args": {"single_line": false} },
{ "keys": ["tab"], "command": "reindent", "args": {"single_line": true} }
]

I'm trying to sort out the difference between single_line:true and single_line:false. At first, it seemed that single_line:false simply reindents the entire file. But upon closer inspection, it seems to reindent differently.

Take this single line example of javascript code:

var app = angular.module('indexApp', ['chart.js', 'ui.toggle']);

Hitting F5 (single-line:false) keeps the line at the left margin (which seems correct to me)

Hitting TAB (single_line:true) indents the line by one

Hitting F5 toggles it back to the left margin.

So, what's the single_line:true/false really mean ?

Upvotes: 0

Views: 365

Answers (1)

Chad Burkins
Chad Burkins

Reputation: 155

Hmmm, it looks like 'single_line' is not my issue here.

Looks like this is my issue: https://github.com/SublimeTextIssues/Core/issues/1271

There seems to be a feature that is causing Javascript (and other) comments to not be indented "correctly". (at least according to my definition of correct).

The fix in the linked issue above works for me... (though I'm guessing I'll lose the fix if I ever update ST) ?

Upvotes: 1

Related Questions