0

SQL Server Management Studio 2012 has some strange behaviour.

For example I have the following query:

if year(getdate()) = 2013
    select 'two thousand and thirteen';

if year(getdate()) = 2014
    select 'two thousand and fourteen';

There is no symbol on the third line. Just new line.

I put the cursor at the end of the second line and push the Down arrow button.

Here the magic begins. Cursor moves not to the first column of the third line but to the fifth one.

If I push the End button cursor moves to it's real position: first column.

Can somebody explain why such strange behaviour happens and how to fix it?

P.S. Do not offer choosing Indenting-None option. Because I need indenting when editing my code. When I push the Enter button I need cursor to be indented on a new line. Problem is mainly with displaying the code and not with formatting it.

GriGrim
  • 2,891
  • 1
  • 19
  • 33

1 Answers1

0

SSMS preserves the indenting of the line it came from. Microsoft calls it smart indenting. The behavior you are looking for is Block indenting. It is located in the Options of SSMS:

enter image description here

TTeeple
  • 2,913
  • 1
  • 13
  • 22
  • Indenting Block doesn't help. Behaviour is the same. – GriGrim Feb 18 '14 at 13:42
  • Do you have another add-on installed that could be preventing these changes from going through? Also, you need to make sure it is changed for All Languages, Plain Text, and Transact-SQL, otherwise it will have conflicting options. – TTeeple Feb 18 '14 at 13:45
  • Yes, I do have. But my colleague doesn't have any add-on and he has the same problem. – GriGrim Feb 18 '14 at 13:50
  • I was able to get the behavior you are looking for by changing them all to None. – TTeeple Feb 18 '14 at 13:52
  • See my last sentence in the answer: `Do not offer choosing Indenting-None option`. Because I need Indenting-Block while writing code. When I push Enter at the end of the line I need cursor to be indented. My problem is not all about indenting. It is about displaying code. – GriGrim Feb 18 '14 at 14:03
  • Then you are contradicting yourself. You asked "Can somebody explain why such strange behaviour happens and how to fix it?" I interpret that as you don't want the indenting to happen, which changing the Identing to None is the solution. Maybe you should update your question to properly reflect what you are asking? – TTeeple Feb 18 '14 at 14:06