views:

76

answers:

3

When I am editing my aspnetmvc views, I begin my code brackets:

<%

and intellisense pops up items like

<%@ Assembly... <%@ Control... <%@ etc...

which is fine, but when I continue my line and press the [=] key, it automatically selects <%@ Assembly=%> and completes my tag.

It's not a huge deal, but does slow me down a bit, especially when editing forms with lost of fields.

Has anyone run into this problem in the past and is there a way to either add <%= to intellisense or stop returning the other directives when I hit [=].

I remember seeing the same issue in one of Phil Haacks recent demos (he says something like "What was that?" and then continues on) but I can't remember which one.

Thanks for the help,

Hal

A: 

I think I found an answer. I created the following macro:

Option Strict Off
Option Explicit Off
Imports System
Imports EnvDTE
Imports EnvDTE80
Imports EnvDTE90
Imports System.Diagnostics

Public Module RecordingModule


    Sub CleanupImplementedInterface()
    DTE.ActiveDocument.Selection.LineDown(True, 7)
    DTE.ActiveDocument.Selection.Text = " {get"
    DTE.ActiveDocument.Selection.DeleteLeft(3)
    DTE.ActiveDocument.Selection.Text = " get; set; }"
    DTE.ActiveDocument.Selection.CharRight
    DTE.ExecuteCommand ("Edit.Replace")
    DTE.Find.FindWhat = " {"
    DTE.Find.Target = vsFindTarget.vsFindTargetCurrentDocument
    DTE.Find.MatchCase = False
    DTE.Find.MatchWholeWord = False
    DTE.Find.Backwards = False
    DTE.Find.MatchInHiddenText = True
    DTE.Find.PatternSyntax = vsFindPatternSyntax.vsFindPatternSyntaxLiteral
    DTE.Find.Action = vsFindAction.vsFindActionFind
    If(DTE.Find.Execute() = vsFindResult.vsFindResultNotFound) Then
Throw New System.Exception("vsFindResultNotFound")
End If
    DTE.Windows.Item("{CF2DDC32-8CAD-11D2-9302-005345000000}").Close
    DTE.ActiveDocument.Selection.CharLeft
    End Sub
    Sub Brackets()
    DTE.ActiveDocument.Selection.Text = "<%="
    End Sub
End Module

Then in the IDE, I opened Tools > Options > Environment > Keybord

In the "Show commands containing:" textbox I typed the name of my macro.

I then selected "Html source editor" in the "Use new shortcut in:" dropdown box and pressed the shortcut key Alt-B.

Now, whenever I need a bracket, instead of using intellisense, I just press Alt-B in the editor.

Ugly, but workable, solution. Hopefully they will fix this in 2010. Haven't looked.

Hal
+1  A: 

Or there is the simple solution :)

Press these keys: < % Esc =

Jon Grant
:-) True. Accept.
Hal
A: 

Type Cntl-Z twice and the automatic change will be undone. You can do this for anything unwanted Intellisense suggestions.

Jon Price