Auto-indent after newline when typing T-SQL

Discussion of open issues, suggestions and bugs regarding database management and development tools for SQL Server
Post Reply
MEngelbyDev
Posts: 33
Joined: Tue 06 Dec 2016 19:49

Auto-indent after newline when typing T-SQL

Post by MEngelbyDev » Fri 24 Feb 2017 17:03

When typing in an T-SQL statement, a SELECT for example, after I press the <enter> key, the cursor is indented by 4 characters from the previous line. Like this:

Code: Select all

SELECT  *
    |<--- insertion cursor is here
I'd prefer not to indent after pressing <enter>. The formatting I use is like this:

Code: Select all

SELECT  u.*
FROM    dbo.Users AS u
WHERE   u.UserID = @UserID;
My typing stream is 'SELECT <tab> u.* <enter> FROM <tab> dbo.Users AS u <enter> WHERE <tab> u.UserID = @UserID; <enter>". I like the extensive formatting options that Studio has. I've made my own profile (copied from default) and have modified that for my coding style. I primarily use it when refactoring code that is a horrible mess. For new code, it is working against me or perhaps I am working against the feature. I cannot find where to turn off the auto-indent after newline. With the amount of options available, I'm sure it's in there. :oops: Perhaps I am using auto-format incorrectly and need a correction in my habits. I don't discount that either.

alexa

Re: Auto-indent after newline when typing T-SQL

Post by alexa » Fri 24 Feb 2017 17:11

Please perform the following:
1. Select 'Tools -> Options...' from the main menu. The 'Options' window opens.
2. Navigate to the 'Text Editor -> Tabs' section.
3. Select 'None' under 'Indenting'.

MEngelbyDev
Posts: 33
Joined: Tue 06 Dec 2016 19:49

Re: Auto-indent after newline when typing T-SQL

Post by MEngelbyDev » Fri 24 Feb 2017 17:34

HA!! I knew it was in there! Thanks for the assist. Much appreciated. :mrgreen:

Incidentally, I set the indenting option to BLOCK to get the effect I wanted. My T-SQL statements are almost always inside blocks (anonymous or otherwise).

alexa

Re: Auto-indent after newline when typing T-SQL

Post by alexa » Fri 24 Feb 2017 18:01

Thank you for the reply.

Please let us know if any questions arise.

Post Reply