Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You could add this macro to your VS config (via Tools -> Macros -> Macro Explorer) then assign a hotkey to it (via Tools -> Options -> Environment -> Keyboard).</p> <p>I only just wrote it (been meaning to try this for ages!) but it seems to work so far, in both VS2008 and VS2010.</p> <p>Since it's a macro you can edit it to include whatever rules you want (e.g. looking in other folders, or special naming rules if you have a single header shared by multiple cpp files or similar).</p> <p>Here's the macro (I'm sure it could be better written; I'm unfamiliar with the VS objects and only realised macros were using .Net about half-way through writing the thing :)):</p> <pre><code>Sub FileSwitch() Try Dim CurrentPath As String = DTE.ActiveDocument.FullName Dim OtherPath As String If (IO.Path.HasExtension(CurrentPath)) Then Dim CurrentExtension As String = IO.Path.GetExtension(CurrentPath) Select Case CurrentExtension Case ".h", ".hpp", ".hxx" OtherPath = IO.Path.ChangeExtension(CurrentPath, ".cpp") If (Not IO.File.Exists(OtherPath)) Then OtherPath = IO.Path.ChangeExtension(CurrentPath, ".c") If (Not IO.File.Exists(OtherPath)) Then OtherPath = IO.Path.ChangeExtension(CurrentPath, ".cxx") End If End If Case ".cpp", ".c", ".cxx" OtherPath = IO.Path.ChangeExtension(CurrentPath, ".h") If (Not IO.File.Exists(OtherPath)) Then OtherPath = IO.Path.ChangeExtension(CurrentPath, ".hpp") If (Not IO.File.Exists(OtherPath)) Then OtherPath = IO.Path.ChangeExtension(CurrentPath, ".hxx") End If End If Case Else End Select If (OtherPath &lt;&gt; Nothing) Then DTE.ItemOperations.OpenFile(OtherPath) End If End If Catch ex As System.Exception MsgBox(ex.Message) End Try End Sub </code></pre> <p>Here's a (very wide :)) screenshot showing what the macro editor and hotkey/options dialogs should look like, to help those not familiar with them:</p> <p><img src="https://i.stack.imgur.com/r5d1a.png" alt="enter image description here"></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload