2013-12-15 19 views

risposta

1

Ok ecco la risposta come macro che ho costruito, che lo fa (commutazione) tra cui andare a fuoco:

Ecco la demo:

enter image description here

Ed ecco il codice, buon divertimento!

Imports System 
Imports EnvDTE 
Imports EnvDTE80 
Imports EnvDTE90 
Imports EnvDTE90a 
Imports EnvDTE100 
Imports System.Diagnostics 
Imports System.Windows.Forms 

Public Module Module2 
    Sub beginToEnd() 

     'Place cursor somewhere in beginning tag, run macro, to select from beginning to End Tag 

     DTE.ActiveDocument.Selection.SelectLine() 
     Dim objSel As TextSelection = DTE.ActiveDocument.Selection 
     Dim topPoint As TextPoint = objSel.TopPoint 
     Dim lTopLine As Long = topPoint.Line 
     objSel.GotoLine(lTopLine, False) 
     ' DTE.ActiveDocument.Selection.StartOfLine() 
     DTE.ActiveDocument.Selection.SelectLine() 
     Dim line1 As String = DTE.ActiveDocument.Selection.Text() 
     If InStr(line1, "/") Then 

      ' MsgBox(line1) 
      DTE.ExecuteCommand("Edit.ToggleOutliningExpansion") 
      DTE.ActiveDocument.Selection.EndOfLine() 
      DTE.ActiveDocument.Selection.StartOfLine(vsStartOfLineOptions.vsStartOfLineOptionsFirstText, True) 
      objSel.GotoLine(lTopLine, False) 
      DTE.ExecuteCommand("Edit.ToggleOutliningExpansion") 
      DTE.ExecuteCommand("Edit.ToggleOutliningExpansion") 


     Else 

      DTE.ExecuteCommand("Edit.ToggleOutliningExpansion") 
      DTE.ActiveDocument.Selection.EndOfLine(False) 
      DTE.ExecuteCommand("Edit.ToggleOutliningExpansion") 

     End If 
     DTE.ActiveDocument.Selection.SelectLine() 
     Dim line2 As String = DTE.ActiveDocument.Selection.Text() 
     Dim objSel3 As TextSelection = DTE.ActiveDocument.Selection 
     Dim topPoint3 As TextPoint = objSel3.TopPoint 
     Dim lTopLine3 As Long = topPoint3.Line 
     objSel.GotoLine(lTopLine3, False) 
     DTE.ActiveDocument.Selection.StartOfLine(vsStartOfLineOptions.vsStartOfLineOptionsFirstText, False) 


    End Sub 



End Module 
3

ho sentito che ctrl + ] fa il trucco

+2

No. Se il cursore si trova '< body> aaaaaa' e si preme 'Ctrl]' vi porterà '> aaaaaa' 'e non AAAAAA </body>', se lo desideri –

+2

@ RoyiNamir +1 per i tuoi sforzi nei commenti :) – nawfal

+0

Sì Ctrl +] ti porta alla parentesi di chiusura, non al tag di chiusura. Ho pubblicato un altro metodo che potresti usare. –

5

Da quello che ho raccolto non ci sono scorciatoie per questo sia in ReSharper o Visual Studio. Un "aggiramento" potrebbe essere quello di comprimere il tag usando Ctrl + M + M, quindi andare all'inizio o alla fine della riga usando il tasto Home o Fine. Quando lo apri di nuovo usando Ctrl + M + M sarai nella parte superiore o inferiore del tag.

  • Ctrl + M + M
  • casa/End (A seconda se si vuole andare al punto di partenza o di tag finale)
  • Ctrl + M + M
Problemi correlati