Using Visual Studio 2008 Team Edition, is it possible to assign a shortcut key that switches between markup and code? If not, is it possible to assign a shortcut key that goes from code to markup?
+2
A:
The following is a macro taken from a comment by Lozza on http://www.codinghorror.com/blog/archives/000315.html. You just need to bind it to a shortcut of your choice:
Sub SwitchToMarkup()
Dim FileName
If (DTE.ActiveWindow.Caption().EndsWith(".cs")) Then
' swith from .aspx.cs to .aspx
FileName = DTE.ActiveWindow.Document.FullName.Replace(".cs", "")
If System.IO.File.Exists(FileName) Then
DTE.ItemOperations.OpenFile(FileName)
End If
ElseIf (DTE.ActiveWindow.Caption().EndsWith(".aspx")) Then
' swith from .aspx to .aspx.cs
FileName = DTE.ActiveWindow.Document.FullName.Replace(".aspx", ".aspx.cs")
If System.IO.File.Exists(FileName) Then
DTE.ItemOperations.OpenFile(FileName)
End If
ElseIf (DTE.ActiveWindow.Caption().EndsWith(".ascx")) Then
FileName = DTE.ActiveWindow.Document.FullName.Replace(".ascx", ".ascx.cs")
If System.IO.File.Exists(FileName) Then
DTE.ItemOperations.OpenFile(FileName)
End If
End If
End Sub
Luke Bennett
2008-09-23 08:40:44
A:
Not sure if this is what you mean, as I don't do ASPX development myself, but don't the F7 (show code) and Shift-F7 (show designer) default key bindings switch between code and design? They do in my VS2008 (on WinForms designable items) with the largely default C# key bindings I use.
peSHIr
2010-08-12 10:24:13
They switch between the designer (wysiwyg) and code view but not the markup view. I find this particularly annoying by the way.
Sandor Drieënhuizen
2010-08-12 11:51:49