Home»ProductsWebsite updated: Nov 30, 2016

For developers: Skripts

Back to the list with tips & tricks

In the following you can see two scripts that allow you to jump to the previous or next function which is quite useful for navigating in the source code. Yuu should define a hotkey for each of like, for example Ctrl+Shift Up/Down. The scrips assume that functions are marked by having a '{' in the first column:

Sub FunctionUp
'DESCRIPTION: Scrollt aufwärts bis zur nächsten Funktion
   Dim StartLine, LastLine, line

   StartLine  = ActiveDocument.Selection.CurrentLine

   line=StartLine-1
   ActiveDocument.Selection.PageUp
   ActiveDocument.Selection.GoToLine line

   While (line>0)
 	 ActiveDocument.Selection.SelectLine
	 If (InStr(1, ActiveDocument.Selection, "{", vbTextCompare)=1) Then
	    Exit Sub
	 End If

	 line=line-1
	 If ((line Mod 40) = 0) Then
		ActiveDocument.Selection.PageUp
	 End If

 	 ActiveDocument.Selection.GoToLine line
   Wend

   ActiveDocument.Selection.GoToLine StartLine
End Sub

Sub FunctionDown
'DESCRIPTION: Scrollt aufwärts bis zur nächsten Funktion
   Dim StartLine, LastLine, line

   StartLine  = ActiveDocument.Selection.CurrentLine

   line=StartLine+1
   ActiveDocument.Selection.PageDown
   ActiveDocument.Selection.GoToLine line

   While (line = ActiveDocument.Selection.CurrentLine)
 	 ActiveDocument.Selection.SelectLine
	 If (InStr(1, ActiveDocument.Selection, "{", vbTextCompare)=1) Then
	    Exit Sub
	 End If

	 line=line+1
	 If ((line Mod 40) = 0) Then
		ActiveDocument.Selection.PageDown
	 End If

 	 ActiveDocument.Selection.GoToLine line
   Wend

   ActiveDocument.Selection.GoToLine StartLine
End Sub
Sync Outlook · Synchronize Files · Sitemap · PAD · Mobile version · © 1999-2016 ITSTH