Bug #78245 Inconsistent indentation
Submitted: 27 Aug 2015 17:44 Modified: 3 Feb 11:57
Reporter: Sergio Bobillier Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Workbench: SQL Editor Severity:S4 (Feature request)
Version:6.3.4.0, 6.3.10 OS:Ubuntu (14.04 Trusty)
Assigned to: CPU Architecture:Any
Triage: Needs Triage: D5 (Feature request)

[27 Aug 2015 17:44] Sergio Bobillier
Description:
The SQL Editor in MySQL Workbench has a nice auto indent feature that keeps the indentation you had in the last line when you press enter, however there is a problem with this feature.

The auto-indent feature in the editor indents using spaces, however when you press TAB MySQL Workbench inserts a TAB character, not spaces, causing the indentation to be inconsistent in your SQL Files.

How to repeat:
Create a new SQL Script tab.

Insert some text, for example: 

CREATE TABLE Product(

Press enter on your keyboard. in the next line hit TAB to indent the code, then type more text, for example:

product_id INT NOT NULL PRIMARY KEY AUTO_INCREMENT,

Press enter again. MySQL Workbench will keep your indentation level by inserting four spaces, then insert more text like:

name VARCHAR(100)

This produces this effect:

CREATE TABLE Product(
	product_id INT NOT NULL PRIMARY KEY AUTO_INCREMENT,
    name VARCHAR(100)

(You can't see the difference in the SQL Editor but you will see it in other editors like Sublime Text or in version control diff tools)

Suggested fix:
There are two possible fixes for this:

One is to make the auto-indent feature use tabs, the other is change the SQL Editor so that it inserts soft tabs (four spaces) when you hit the TAB key.

Another, better yet solution is to allow the user to customize this feature, like most editors and IDEs do.
[3 Feb 11:57] Umesh Shastry
Hello Sergio Bobillier,

Thank you for the feedback.

Thanks,
Umesh