Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Configuring Code Editor?

Status
Not open for further replies.

happyabc

IS-IT--Management
Mar 10, 2004
164
IN
Now that my project has grown big, and has deeper nested code, I'd like to reduce the indenting tab blanks from the default 4 to 2 so as to bring more code into view. But to my disappointment, the change affects only new lines and all the old lines are still indented by 4 blanks. Is there any way to make the old tabs also 2 blanks?
 
Tabs in vb are stored as spaces. So you can use normal search and replace. Replace each instance of four spaces with two spaces.

Open the .frm, .cls, .mod file using notepad. (backup them first to be safe)

Replace " " with " " (ignore the quotes)

You will probally need to find/replace interactively, since there may be situations where you want to keep 4 spaces so dont use replace all.
 
Nice idea! But I've got 5000 statements!
 
Why not write a small program to do it, then? Have it iterate through the .cls, .frm and .bas files in a directory, and change 4 spaces to 2 spaces.

Be aware that you need to watch out for spaces in string literals.

Chip H.


____________________________________________________________________
If you want to get the best response to a question, please read FAQ222-2244 first
 
Thats the catch. I also have a 14000 record cdf waiting to be impotred into mdb but I havn't got around to it because its so tricky ( VisData is giving failing after only 45 records ). Know of any source code for the job.
 
Go procedure to procedure or module to module and use the built in find and replace - 4 spaces for 2. Try it in a test module it works. Personally I think it going to be harder to read, 4 spaces seems ideal, just get a bigger monitor:)

Two strings walk into a bar. The first string says to the bartender: 'Bartender, I'll have a beer. u.5n$x5t?*&4ru!2[sACC~ErJ'. The second string says: 'Pardon my friend, he isn't NULL terminated'.
 
That would be replace all not replace, replace, replace.

Two strings walk into a bar. The first string says to the bartender: 'Bartender, I'll have a beer. u.5n$x5t?*&4ru!2[sACC~ErJ'. The second string says: 'Pardon my friend, he isn't NULL terminated'.
 
I have done this in the past... This is what you Do...

1) Open your VB Project
2) Open Microsft Word
3) Open your first Code window
4) Copy all the Code into a Blank Word Document
5) In word do a search and replace
Search "^P "
Replace "^P "
6) Hit "Replace All" several times until it does not find any matches.
7) Copy the Code from Word Back to VB.
8) Repeat steps 3 through 7 for each code module.

Craig


Casper

There is room for all of gods creatures, "Right Beside the Mashed Potatoes".
 
Actually That above wouldn't work? It would remove all your indents...

Here is some code that would do it...

Code:
Private Function ConvertCode(i_sCode As String, i_iFrom As Integer, i_iTo As Integer) As String
    Dim x As Integer
    Dim y As Integer
    Dim bFound As Boolean
    Dim aLines
    Dim o_sCode As String
    
    aLines = Split(i_sCode, vbCrLf)
    For x = 0 To UBound(aLines)
        bFound = False
        y = 1
        Do Until bFound
            If Mid(aLines(x), y, i_iFrom) = Space(i_iFrom) Then
                y = y + i_iFrom
            Else
                bFound = True
                o_sCode = o_sCode & Space(y / i_iFrom * i_iTo) & Mid(aLines(x), y) & vbCrLf
            End If
        Loop
    Next x
    ConvertCode = o_sCode
End Function

Casper

There is room for all of gods creatures, "Right Beside the Mashed Potatoes".
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top