Code folding was recently added for VBScript for the Ace Code Editor which is great but I noticed an issue. If the keyword isn't the first word on the line, then folding doesn't work properly for the entire script. For example:
This folds correctly:
Sub ThisisASubroutine()
End Sub
but this doesn't:
Protected Sub ThisisASubroutine()
End Sub
Related
When I wirte the following example code (in VBscript) in Notepad++
dim X
X = Array( "string1", _
"string2", _
"string3" )
Wscript.Echo X(1)
it looks as follows:
As you can see, the three blank lines are inside the code block which one can collapse and uncollapse, which is an annoying behavior. I'd rather have these three lines outside the array group like here, but without REM:
Is there a setting of Notepad++ I am missing to get the desired behaviour?
You can utilized custom language defined settings to make custom fold begin and end objects. This will allow you to insert start and end paramaters within your code so folding done by your configuration.
Here, the language is set to VB and includes the blank spaced lines.
Click on the User Defined Languages Icon(sorry for bad drawing....).
Here, i've saved the user language as Custvbs and applied '{ and '} as my start/end blocks for folding. There is an additional field for secondary folding labelled Folding in code 2 style (seperators needed)
And here is the resulting custom fold:
How about removing the surplus blank lines. You can do this by selecting TextFX -> TextFX Edit -> Delete Surplus Blank Lines
I have inherited a VB6 app and I could do with some help with part of it.
The code opens a word document and copies its contents. Once this is complete it will open another document and paste the contents from the first document into the second. The opening, copying and pasting works ok, the issue comes with the formatting of the pasted text and the section break it follows. Instead of appearing straight after the section break it is being put on another page, the section break does however still say it is continuous. I've done some digging and tried what it says in the following
Stop Margin Adjustment when pasting - Microsoft Community
Problems with margins when I copy and paste a document into template - Microsoft Community
Section break causes unexpected page break in word
Troubleshoot page breaks and section breaks - Word - Office.com
None of these have helped. A cut down version of the code is as follows:
GetWord97Object objWordApp
objWordApp.Visible = True
objWordApp.documents.Open strCopyFromDoc
DeleteHeadersAndFooters objWordApp.documents(strCopyFromDoc)
objWordApp.documents(strCompyFromDoc).content.Copy
objWordApp.documents.Open strCopyToDoc
objWordApp.documents(strCopyToDoc).characters(objWordApp.ActiveDocument.characters.Count).Select
Set objRng = objWordApp.ActiveDocument.content ' Range used so as not to overwrite original text
objRng.Collapse Direction:=0
If IsWordAppVersionLessThan2002(CInt(objWordApp.Version)) Then
objRng.Paste
Else
objRng.PasteAndFormat wdPasteDefault
End If
I've tried the paste and format but that hasn't helped.
The version of Word I am using is 2002 SP3 but I need it to work with 2002 and up. The VB6 is at SP6.
Thanks in advance for your help.
I've managed to get rid of the problem. It looks like it was something to do with the document, rather than the code. I've given copying the header and footer from one document to another and that seems to have worked this time. Previous attempts at copying didn't seem to make any difference. Not an ideal solution but at least it is sorted.
I've found the solution and It's more simple that I thought. Just save the document before you paste your content. That makes Word to keep the original margins definitions. In my code I did that.
Private Sub CommandButton4_Click()
Dim Item As String
Dim i As Integer
For i = 0 To ProcList.ListCount - 1
Dim docNew As Document
Dim docproc As Document
Set docNew = Word.ActiveDocument
docNew.Content.Copy
Set docproc = Documents.Add
With docproc
.SaveAs FileName:=ProcList.List(i)
Selection.ClearParagraphAllFormatting
Selection.Paste
End With
Next i"
Sometimes when i'm working in visual studio, I end up with a block of code that I need to indent a single space in order to make it align completely.
A normal sized indent would be done by selecting the text and pressing the tab key, however if I just want to move it along one space, selecting the text and pressing the space bar overwrites the code.
I know I could do this this by changing the tab spacing option so the indent size is 1, indenting the text and then changing it back but this seems a bit longwinded...
I've had no luck searching, so I've written a macro to do the above, but I thought i'd ask on here before i resigned to using it just in case the function/shortcut already existed...
Edit: Macro moved to answers
Here is said macro for anyone interested:
Sub SingleSpaceIndent()
Dim textEditor As Properties
textEditor = DTE.Properties("TextEditor", "AllLanguages")
textEditor.Item("IndentSize").Value = 1
DTE.ActiveDocument.Selection.Indent()
textEditor.Item("IndentSize").Value = 4
End Sub
i'm looking for a way to write a macro event to parse user's code.
for example when programmer writes some specific code this event will parse the code line and if matches a regular expression will insert some additional codes on active document.
how can i get hole line code and which event should i use?
You can use TextDocumentKeyPressEvents.AfterKeyPress event. The following macro triggers after user presses any key in text editor. Then it gets the current line. This example tests, if the line contains "hello" text and if so, it shows the line in message box.
Private Sub TextDocumentKeyPressEvents_AfterKeyPress(ByVal Keypress As String, _
ByVal Selection As EnvDTE.TextSelection, ByVal InStatementCompletion As Boolean) _
Handles TextDocumentKeyPressEvents.AfterKeyPress
Try
Dim line As String
Dim aPoint As EditPoint = Selection.ActivePoint.CreateEditPoint
Dim startPoint As EditPoint = aPoint.CreateEditPoint
startPoint.StartOfLine()
Dim endPoint As EditPoint = aPoint.CreateEditPoint
endPoint.EndOfLine()
line = startPoint.GetText(endPoint)
If line.Contains("hello") Then
MsgBox(line)
End If
Catch ex As Exception
End Try
End Sub
To create and apply this macro:
Go to menu Tools - Macros - Macros IDE...
In the Macros IDE Class View navigate to MyMacros - {}
MyMacros - EnvironmentEvents. Open (double-click) EnvironmentEvents.
Paste this code inside module (just before End Module line)
There are events that Macros can respond to, however, I do not believe that text entry is one of them, a better approach might be to use snippets - http://msdn.microsoft.com/en-us/library/ms165392(v=VS.100).aspx
They will allow you to define a keyword and then add text into the editor.
A good example is the property snippet; In your editor type 'prop' and then press Tab (twice in C#, once in VB) to invoke.
Here is more detailed list of available snippets:
http://msdn.microsoft.com/en-us/library/z41h7fat(v=VS.100).aspx
Does Ruby have block comments?
If not, is there an efficient way of inserting # in front of a block of highlighted code in TextMate?
You can do
=begin
[Multi line comment]
=end
=begin and =end must be at the beginning of the line (not indented at all).
Source
Also, in TextMate you can press Command + / to toggle regular comments on a highlighted block of code.
Source
Ruby has documentation comments - they look like this:
=begin
...
=end
Not perfect but they get the job done in a pinch.
[Edit] It is important to note that =begin and =end must be at the beginning of their respective lines.
In TextMate, you can alt-drag vertically to select a column of text. This will duplicate the insertion point across all the lines you select, so you can insert or delete multiple #s at once.
UPDATE: Also in TextMate, assuming you have the right language selected, Cmd + / will toggle commenting every line in a selection regardless of language.
In TextMate 2 you can ⌘/ to comment out the current line or selected lines.