programing

VC ++에서 헤더와 소스 파일 사이를 이동할 수있는 바로 가기가 있습니까?

nasanasas 2020. 8. 20. 18:58
반응형

VC ++에서 헤더와 소스 파일 사이를 이동할 수있는 바로 가기가 있습니까?


이것은 내가 이클립스 ( Ctrl+ Tab) 에서 익숙해 진 기능 이다. Visual C ++에 동등한 것이 있습니까?


Visual Studio 2013 이상에는 이에 대한 기본 바로 가기 키가 있습니다. Ctrl+ K, Ctrl+ O( Ctrl 을 누른 상태에서 ko를 입력 한 다음 Ctrl을 놓아야합니다 )

이전 버전에서는 다음을 참조하십시오.

CPP와 H 파일 간 전환을위한 Visual Studio 매크로

또는

Visual Assist에서 해당 파일 열기


Visual Studio 2013에서 이에 대한 기본 바로 가기 키는 Ctrl+ K, Ctrl+입니다.O


이 매크로를 VS 구성에 추가 한 다음 (도구-> 매크로-> 매크로 탐색기를 통해) 핫키를 할당 할 수 있습니다 (도구-> 옵션-> 환경-> 키보드를 통해).

나는 단지 그것을 썼을뿐 (오랜 동안 이것을 시도하는 것을 의미했다!)하지만 지금까지 VS2008과 VS2010 모두에서 작동하는 것 같다.

매크로이기 때문에 원하는 규칙을 포함하도록 편집 할 수 있습니다 (예 : 다른 폴더 또는 여러 cpp 파일 또는 유사한 파일에서 단일 헤더를 공유하는 경우 특수 이름 지정 규칙).

다음은 매크로입니다 (더 잘 작성 될 수 있다고 확신합니다. 저는 VS 객체에 익숙하지 않고 매크로 만 .Net을 사용하고 있다는 것을 깨달았습니다. :)) :

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 <> Nothing) Then
                DTE.ItemOperations.OpenFile(OtherPath)
            End If
        End If

    Catch ex As System.Exception
        MsgBox(ex.Message)
    End Try
End Sub

다음은 매크로 편집기와 핫키 / 옵션 대화 상자가 어떻게 생겼는지 보여주는 (매우 넓은 :)) 스크린 샷입니다.

enter image description here


Try Visual Assist, which sports this very feature (amongst others):

http://www.wholetomato.com/

The code browsing functionality -- of which the header/cpp swap is one part -- are really good.

(I also really rated its intellisense and refactoring features, but not everybody I've spoken to has agreed with me.)

EDIT: just remembered, the Nifty Solution Plugin also does this -- plus another handly Visual Assist-like thing, though nothing else -- and they're free:

http://code.google.com/p/niftyplugins/

(The guy's perforce plugin is great, too. Much better than the default VSSCC rubbish.)


Try PhatStudio. It's free and comes with an easy installer.

  • ALT + S = Switch between header/source file

  • ALT + O = Open a file (supports instant search via typing, like the start menu in Windows Vista/7).


In Visual Studio 2008 and 2010, you can right click in your .cpp file and choose Go To Header File ... that will take you in one direction. For the other direction, if you right click something you're declaring in the header, and choose Go To Definition, that will take you in the other direction. You might have to go through an ambiguity resolution dialog if you choose the constructor, because the function name matches the class name, but if you choose anything else, you'll go straight where you want. I know this is a two-click approach, rather than one keystroke, but it does do what you want.


If you position your mouse over a function declaration in the header and press F12, the cpp file will be opened at the definition of the cpp file... I use this feature extensively!


I don't see this answer here, but at least in Visual Studio 2012 (Express included!), you can just assign your own keyboard command to go to the header file (NOTE: Only goes one way -- you can't go back to the source file unfortunately...)

  1. Go to Tools/Options/Environment/Keyboard.
  2. Find the following command: EditorContextMenus.CodeWindow.GoToHeaderFile
  3. Assign whatever key combination you want (Alt-S works)
  4. Profit

Not sure which versions of VS this works in, but it doesn't require any add-ins and seems to do the trick in at least one direction.


Try using Switch - it's an addin that lets you flick between source and header, code and designer, XAML and codebehind etc etc:

http://www.dwmkerr.com/switch/ or directly from Products and Extensions for Visual Studio


I'm a fan of Visual Assist for doing this. Its not cheap but it provides a lot more functionality than switching between header and source. I also use its open file in project and class browsing features a lot. Of course the macro is free...


There's also a macro listed on the Whole Tomato support forum which has a few more file mappings.


For Visual Studio 2013, as mentioned by others it's the command named:

EditorContextMenus.CodeWindow.ToggleHeaderCodeFile

and it has as default combination of keys: Ctrl+K,Ctrl+O, but it can be changed if you introduce the new combination of keys that you like in the

Press shortcut keys:

under

Tools -> Options -> Environment -> Keyboard.

So you can choose a custom keys combination as my favorite for .h to .cpp switch is Ctrl+Tab.


Visual assist also does not support Visual studio express editions. So you are stuck with the macro if you are using that IDE>


In Visual Studio 2008 it's Alt + O.


In their (in)finite wisdom, MS decided to remove macros in MSVS 2012, so the macro above won't work.

For MSVS 2012, I found this:

http://www.dwmkerr.com/switch/

It's highly configurable + if you want to help improving it, you can do so on GitHub.


In Visual Studio 2013 it's ALT + O

참고URL : https://stackoverflow.com/questions/2602682/is-there-a-shortcut-to-move-between-header-and-source-file-in-vc

반응형