Re: autoindent mode?

I'm a new user.   I can't figure out how to do autoindent.  I think I have made it work  in my trial version of Outlook ViEmu and I'm quite certain I have used it in my purchased copy for VisStudio, but I can't make it work in SqlServer trial and it is driving me crazy.

thanks for any suggestions.



Re: autoindent mode?

Hi, what do you mean by making autoindent to work? ViEmu under both VS and SQL Server provides the built-in VS or SQL Server autoindent, which is active in insert mode when you press 'return'. This depends on the language service for the type of file you are editing - so it might just be non-existent for non-supported file types. But it doesn't have anything to do with ViEmu - you get the same as with stock VS or SSMS.

ViEmu works like that under Word/Outlook too, but since Word & Outlook don't provide any interesting autoindent, you get nothing. You do get autostyling and autocorrection though, as provided by the Word engine.

Actually, 'insert mode' is mostly the same as having ViEmu pass everything through, thus buying you the underlying input system. Of course, ViEmu remembers what it has passed through for later '.' repetition, and this requires some heavy lifting to properly understand Intellisense autocompletions and so on, but that's about it.

If you disable ViEmu under SqlServer using the Ctrl-Shift-Alt-V hotkey, do you get autoindent back? If not, can you let me know what file type you are editing? I'll try to reproduce it here, or if not, I'll find out how to *restore* autoindent, and then we can work on having ViEmu work fine without disrupting autoindent.


  - Jon


Re: autoindent mode?

Here is some sample  code to hopefully illustrate my problem/question.

I wanted to indent the WHERE clause conditions via "set ai" but that apparently isn't supported. So, I tried using the Indent button on the SSMS toolbar, but that isn't working for me either, or at least not as I expected.

I created the first 3 lines of the OR clause, which were aligned on the left margin, and then manually idented them with the toobar indent button.   I assumed I could go back and add more conditions which would also be indented, but they aren't.  The additional lines were aligned on the left margin - they did not inherit the indentation of the lines above.

I am new to Sql language, SSMS and ViEmu, so it's probably cockpit error.  I appreciate any tips you can provide.


ldh, aka pdawg

==== sample .sql code ====

SELECT Campaign = CampaignId, Session = SessionID
FROM Events
    Sessionid IS NULL
    Sessionid <> 90
OR -- why didn't this indent when this code was added?

Sessionid <> 80 -- why didn't this indent?
-- I used the SSMS Indent button (right arrow icon on toolbar)
ORDER BY SessionId


Re: autoindent mode?

I'm not all too familiar with SQL myself either (ViEmu/SQL is the only one of my products that I don't use all the time). I've been investigating it, and it just seems Management Studio in SQL Server 2005 does not provide auto-indent at all:


Not weird, as they don't support any type of Intellisense-like autocompletion (Red Gate software sells a tool that provides at least autocompletion and seems to provide auto-indentation too, at 200 bucks a pop! - these things always make me rethink my prices, so don't point me in their direction too much smile ). Here's a link: http://www.red-gate.com/products/SQL_Prompt/index.htm .

Ok, so we're down to manual indenting. Using ViEmu, you can use the '>' and '<' operators in normal mode: >> or << for a single line, 5>> or 5<< for 5 lines, >} or <} for the paragraph, V and move around plus > or < for a visual region, etc...

While in insert mode, Ctrl-T and Ctrl-D also indent and unindent the current line.

I don't know whether SQL Server 2008 fixes it (I've just made sure ViEmu works fine with it), although it's still in "CTP" status (some kind of beta).

I'm sorry the lookout is so ugly, there's not much I can do about it. Writing a parser and an autoindent service for SQL is out of my reach by now...


  - Jon


Re: autoindent mode?

It is not a big deal for me to indent the code myself.  I will probably write the code aligned to the left margin, and then when I'm done, pretty it up with a :[range]> command.

Thanks for your quick reply.



Re: autoindent mode?

Good to know. Let me know if anything else acts up!