Author Topic: Replace tabs with spaces  (Read 5008 times)

Siekmanski

  • Member
  • *****
  • Posts: 1646
Replace tabs with spaces
« on: July 17, 2012, 04:49:15 AM »
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

  • Guest
Re: Replace tabs with spaces
« Reply #1 on: July 17, 2012, 05:08:34 AM »
I just do a Find/Replace in Word.  ^t is the escape for a tab.

jj2007

  • Member
  • *****
  • Posts: 8735
  • Assembler is fun ;-)
    • MasmBasic
Re: Replace tabs with spaces
« Reply #2 on: July 17, 2012, 06:36:58 AM »
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

  • Member
  • *****
  • Posts: 1646
Re: Replace tabs with spaces
« Reply #3 on: July 17, 2012, 08:21:38 AM »
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

  • Member
  • *****
  • Posts: 1473
  • The base type of a type is the type itself
    • SmplMath macros
Re: Replace tabs with spaces
« Reply #4 on: July 17, 2012, 08:27:49 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

  • Member
  • *****
  • Posts: 8808
  • Still using Abacus 2.0
    • DednDave
Re: Replace tabs with spaces
« Reply #5 on: July 17, 2012, 09:25:28 PM »
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

  • Member
  • *****
  • Posts: 1646
Re: Replace tabs with spaces
« Reply #6 on: July 18, 2012, 04:39:19 AM »
I'll have a look at Swiss File Knife.
Creative coders use backward thinking techniques as a strategy.

jj2007

  • Member
  • *****
  • Posts: 8735
  • Assembler is fun ;-)
    • MasmBasic
Re: Replace tabs with spaces
« Reply #7 on: July 18, 2012, 05:05:03 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--

  • Administrator
  • Member
  • ******
  • Posts: 5762
  • Mnemonic Driven API Grinder
    • The MASM32 SDK
Re: Replace tabs with spaces
« Reply #8 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. QE does it automatically as you type.
hutch at movsd dot com
http://www.masm32.com    :biggrin:  :biggrin:

Siekmanski

  • Member
  • *****
  • Posts: 1646
Re: Replace tabs with spaces
« Reply #9 on: July 18, 2012, 11:41:19 AM »
Quote
Just 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

  • Regular Member
  • *
  • Posts: 27
  • Toolsmith and Assembler coder (x86,ARM,MIPS,68K)
Re: Replace tabs with spaces
« Reply #10 on: July 19, 2012, 02:43:59 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