News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests

Main Menu

Replace tabs with spaces

Started by Siekmanski, July 17, 2012, 04:49:15 AM

Previous topic - Next topic

Siekmanski

Is there a tool that fills the tabs of a source file with spaces ?
So if I post a source it's better readable if someone uses another tab space ?
Creative coders use backward thinking techniques as a strategy.

Ryan

I just do a Find/Replace in Word.  ^t is the escape for a tab.

jj2007

Instead of launching MS Word, try this - I hope it's self-explanatory ;-)

include \masm32\MasmBasic\MasmBasic.inc   ; download
   Init
   Let esi=Clip$()
   SetClip$ Cat$(Replace$(esi, Tb$, "    "))
   Exit
end start

Siekmanski

Thanks.
I never used MasmBasic.....
Don't know what to do with Tabs2Spaces.exe ?
When I execute the file nothing happens.
Creative coders use backward thinking techniques as a strategy.

qWord

Quote from: Siekmanski on July 17, 2012, 08:21:38 AM
When I execute the file nothing happens.
the current clipboard content is manipulated
MREAL macros - when you need floating point arithmetic while assembling!

dedndave

Swiss File Knife is a command-line tool that does all kinds of stuff
http://sourceforge.net/projects/swissfileknife/
it's easy to write batch files that use it


Siekmanski

I'll have a look at Swiss File Knife.
Creative coders use backward thinking techniques as a strategy.

jj2007

Quote from: qWord on July 17, 2012, 08:27:49 AM
the current clipboard content is manipulated

Which is usually an unfriendly act, but when posting code to the Forum, you need to use it anyway ;-)

Here is a special variant for the Masm32 Forum:

include \masm32\MasmBasic\MasmBasic.inc       ; download
   Init
   Let esi=Clip$()       ; get clipboard text
   SetClip$ Cat$(Replace$(esi, Tb$, "    "))       ; set modified text with 4 spaces per tab
   .if WinByTitle("Post reply -")       ; check if the reply window is already open
      invoke SetForegroundWindow, eax       ; if yes, go there
   .endif
   Exit
end start

Of course, you need to launch the proggie. For use with QEditor, menus.ini needs a line like
Quote[&Tools]
...
Tabs to Spaces,{e}\masm32\Tabs2Spaces.exe

hutch--

Just write the algo, its no big deal to do. You need to know what spacing matches your tab settings but its just arithmetic and spaces as padding. QE does it automatically as you type.

Siekmanski

QuoteJust write the algo, its no big deal to do.

You are right hutch, I'll write it myself. ( I was just in a lazy mood )  :biggrin:
Creative coders use backward thinking techniques as a strategy.

clive

Quote from: hutch-- on July 18, 2012, 08:35:08 AM
Just write the algo, its no big deal to do. You need to know what spacing matches your tab settings but its just arithmetic and spaces as padding.

Thank you, it's not just a find-and-replace, as a TAB attempts to push the column to 8, 4, or 2 characters, or whatever the alignment preference is.

They are pretty much noddy programs, I scratched up some DETABx and RETABx applications in C (I know) to transition between soft and hard tabs.
It's a pity the clowns in Washington DC don't understand the Constitution as well as Edward Snowden