Code Bookmark

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Diarmuid

    #1

    Code Bookmark

    Where is this in VB.net?
    Its in VB6, where you can jump from one bookmark to another, to help
    navigate your code.


  • Rothariger

    #2
    RE: Code Bookmark

    in the text editor panel... or in edit -> bookmarks.
    --
    Salute by the First Time!


    "Diarmuid" wrote:
    [color=blue]
    > Where is this in VB.net?
    > Its in VB6, where you can jump from one bookmark to another, to help
    > navigate your code.
    >
    >
    >[/color]

    Comment

    • Cor Ligthert [MVP]

      #3
      Re: Code Bookmark

      Diarmuid,

      Do you see those blue flags in top of your IDE?

      Cor


      Comment

      • Diarmuid

        #4
        Re: Code Bookmark

        Ok, thanks.
        Now that I know where they are, I added them to my toolbar by going
        View/Toolbars/Text Editor

        "Rothariger " <Rothariger@msn .com> wrote in message
        news:027C9D6B-4E6C-4685-8F33-BB782E16D759@mi crosoft.com...[color=blue]
        > in the text editor panel... or in edit -> bookmarks.
        > --
        > Salute by the First Time!
        >
        >
        > "Diarmuid" wrote:
        >[color=green]
        >> Where is this in VB.net?
        >> Its in VB6, where you can jump from one bookmark to another, to help
        >> navigate your code.
        >>
        >>
        >>[/color][/color]


        Comment

        • Chris Dunaway

          #5
          Re: Code Bookmark

          I set keyboard shortcuts to mine. Ctrl-Alt-B toggles the bookmark on
          and off and Ctrl-B and Ctrl-Shift-B jumps to the next/previous
          bookmarks.

          I also wrote a macro that allows me to jump to the definition of a
          method or variable and at the same time, leave a bookmark. That way I
          can jump to a definition and hit a hot key and jump right back where I
          was.

          Comment

          • Diarmuid

            #6
            Re: Code Bookmark

            Hey, thats cool. Didn't even know you could write macros like that.
            Any chance you'd sent it me? Its diarmuidq at yahoo dot com


            "Chris Dunaway" <dunawayc@gmail .com> wrote in message
            news:1126200588 .371496.54700@g 49g2000cwa.goog legroups.com...[color=blue]
            >I set keyboard shortcuts to mine. Ctrl-Alt-B toggles the bookmark on
            > and off and Ctrl-B and Ctrl-Shift-B jumps to the next/previous
            > bookmarks.
            >
            > I also wrote a macro that allows me to jump to the definition of a
            > method or variable and at the same time, leave a bookmark. That way I
            > can jump to a definition and hit a hot key and jump right back where I
            > was.
            >[/color]


            Comment

            • Diarmuid

              #7
              Re: Code Bookmark

              Hey, thats cool. Didn't even know you could write macros like that.
              Any chance you'd sent it me? Its diarmuidq at yahoo dot com


              "Chris Dunaway" <dunawayc@gmail .com> wrote in message
              news:1126200588 .371496.54700@g 49g2000cwa.goog legroups.com...[color=blue]
              >I set keyboard shortcuts to mine. Ctrl-Alt-B toggles the bookmark on
              > and off and Ctrl-B and Ctrl-Shift-B jumps to the next/previous
              > bookmarks.
              >
              > I also wrote a macro that allows me to jump to the definition of a
              > method or variable and at the same time, leave a bookmark. That way I
              > can jump to a definition and hit a hot key and jump right back where I
              > was.
              >[/color]


              Comment

              • Chris Dunaway

                #8
                Re: Code Bookmark

                Here is the code. The code is pretty simple and there minimal error
                checking.
                It was cobbled together quickly so it could probably be improved, but
                it seems to work. It will only work if called while in a text
                document.

                I have a hotkey assigned to execute the GotoDefinition sub. That sub
                in turn pushes a marker onto a stack (which is a class defined below).
                It then executes the IDE's Edit.GoToDefini tion command.

                Then another hotkey executes the PopMarker sub which retrieves the
                bookmark from the stack and jumps to it.

                Sub GotoDefinition( )
                PushMarker()
                DTE.ExecuteComm and("Edit.GoToD efinition")
                End Sub

                Sub PushMarker()

                Dim txtDoc As TextDocument =
                CType(DTE.Activ eDocument.Objec t("TextDocument "), TextDocument)

                Dim edPt As EditPoint = txtDoc.StartPoi nt.CreateEditPo int

                Dim sel As TextSelection = CType(DTE.Activ eWindow.Selecti on,
                TextSelection)

                edPt.MoveToLine AndOffset(sel.C urrentLine, sel.CurrentColu mn)
                edPt.SetBookmar k()

                MarkerStack.Pus h(New Marker(edPt, sel.CurrentLine ,
                sel.CurrentColu mn))

                End Sub

                Public Sub PopMarker()
                Try

                Dim m As Marker = MarkerStack.Pop
                If Not m Is Nothing Then
                Dim txtDoc As TextDocument =
                CType(DTE.Activ eDocument.Objec t("TextDocument "), TextDocument)
                Dim objSel As TextSelection =
                CType(DTE.Activ eDocument.Selec tion, TextSelection)
                Dim edPt As EditPoint = m.ep

                If edPt.TryToShow( vsPaneShowHow.v sPaneShowCenter ed) Then
                edPt.ClearBookm ark()
                objSel.MoveToLi neAndOffset(m.l ine, m.col)
                End If
                End If
                Catch ex As Exception
                Debug.WriteLine (ex.Message & ": " & ex.StackTrace)
                End Try
                End Sub

                End Module

                Public Class MarkerStack
                Private Shared MarkerS As New Stack

                Shared Sub Push(ByVal m As Marker)
                MarkerS.Push(m)
                End Sub

                Shared Function Pop() As Marker
                If MarkerS.Count > 0 Then
                Return DirectCast(Mark erS.Pop, Marker)
                Else
                Return Nothing
                End If
                End Function

                Shared Sub ClearStack()
                MarkerS.Clear()
                End Sub
                End Class

                Public Class Marker
                Public Sub New(ByVal e As EditPoint, ByVal l As Integer, ByVal c As
                Integer)
                ep = e
                line = l
                col = c
                End Sub

                Public ep As EditPoint
                Public line As Integer
                Public col As Integer
                End Class

                Comment

                • Chris Dunaway

                  #9
                  Re: Code Bookmark

                  Here is the code. The code is pretty simple and there minimal error
                  checking.
                  It was cobbled together quickly so it could probably be improved, but
                  it seems to work. It will only work if called while in a text
                  document.

                  I have a hotkey assigned to execute the GotoDefinition sub. That sub
                  in turn pushes a marker onto a stack (which is a class defined below).
                  It then executes the IDE's Edit.GoToDefini tion command.

                  Then another hotkey executes the PopMarker sub which retrieves the
                  bookmark from the stack and jumps to it.

                  Sub GotoDefinition( )
                  PushMarker()
                  DTE.ExecuteComm and("Edit.GoToD efinition")
                  End Sub

                  Sub PushMarker()

                  Dim txtDoc As TextDocument =
                  CType(DTE.Activ eDocument.Objec t("TextDocument "), TextDocument)

                  Dim edPt As EditPoint = txtDoc.StartPoi nt.CreateEditPo int

                  Dim sel As TextSelection = CType(DTE.Activ eWindow.Selecti on,
                  TextSelection)

                  edPt.MoveToLine AndOffset(sel.C urrentLine, sel.CurrentColu mn)
                  edPt.SetBookmar k()

                  MarkerStack.Pus h(New Marker(edPt, sel.CurrentLine ,
                  sel.CurrentColu mn))

                  End Sub

                  Public Sub PopMarker()
                  Try

                  Dim m As Marker = MarkerStack.Pop
                  If Not m Is Nothing Then
                  Dim txtDoc As TextDocument =
                  CType(DTE.Activ eDocument.Objec t("TextDocument "), TextDocument)
                  Dim objSel As TextSelection =
                  CType(DTE.Activ eDocument.Selec tion, TextSelection)
                  Dim edPt As EditPoint = m.ep

                  If edPt.TryToShow( vsPaneShowHow.v sPaneShowCenter ed) Then
                  edPt.ClearBookm ark()
                  objSel.MoveToLi neAndOffset(m.l ine, m.col)
                  End If
                  End If
                  Catch ex As Exception
                  Debug.WriteLine (ex.Message & ": " & ex.StackTrace)
                  End Try
                  End Sub

                  End Module

                  Public Class MarkerStack
                  Private Shared MarkerS As New Stack

                  Shared Sub Push(ByVal m As Marker)
                  MarkerS.Push(m)
                  End Sub

                  Shared Function Pop() As Marker
                  If MarkerS.Count > 0 Then
                  Return DirectCast(Mark erS.Pop, Marker)
                  Else
                  Return Nothing
                  End If
                  End Function

                  Shared Sub ClearStack()
                  MarkerS.Clear()
                  End Sub
                  End Class

                  Public Class Marker
                  Public Sub New(ByVal e As EditPoint, ByVal l As Integer, ByVal c As
                  Integer)
                  ep = e
                  line = l
                  col = c
                  End Sub

                  Public ep As EditPoint
                  Public line As Integer
                  Public col As Integer
                  End Class

                  Comment

                  Working...