somehow, after editing a file on different OS's, I wound up with mixed spaces and tabs, does anyone know of a smart code reformatter that will replace spaces with tabs?
note that in some areas there are 3 spaces and at others 4 or 5 spaces.
I tried search and replace, but it will take me forever to finish, especially troublesome are tabs between asm instructions and operands, as the instructions vary in length, you may need 1 or 2 tabs between instruction and operand to make them line up.
smart code formatter
Re: smart code formatter
The RichMasm editor has an autoformat function, but it's very specialised on x86 assembler. It would be helpful if you posted a hundred lines of example code... how many lines is the source you want to reformat?
Re: smart code formatter
there are about 2100 lines of code including spacers between functions/subs, it's a mix of FB code and inline asm.
Re: smart code formatter
Do you want to make a test? If it's not confidential, upload it somewhere, otherwise post a hundred lines here. If you prefer, I can give you my email here, but it would disappear asap.
Re: smart code formatter
Sound like fun.
I can only give some advice on how to prevent it:
1) Always use an editor that shows white-space characters
2) Don't use tabs between statements (only for indentation)
I had a productive evening yesterday as well. After 1 hour of coding, I accidentally deleted it all by pasting some other code over it instead of inserting. Discovered it only later after saving and closing the file.
I can only give some advice on how to prevent it:
1) Always use an editor that shows white-space characters
2) Don't use tabs between statements (only for indentation)
I had a productive evening yesterday as well. After 1 hour of coding, I accidentally deleted it all by pasting some other code over it instead of inserting. Discovered it only later after saving and closing the file.
Re: smart code formatter
@jj2007
I don't want to post code here, no need to give people a headache, thanks for the offer though, in the meantime, several iterations of search&replace does the job.
offtopic, I found that it's easy to call the mingw sscanf and sprintf to input/output 80-bit reals.
I don't want to post code here, no need to give people a headache, thanks for the offer though, in the meantime, several iterations of search&replace does the job.
offtopic, I found that it's easy to call the mingw sscanf and sprintf to input/output 80-bit reals.
-
- Posts: 252
- Joined: Mar 12, 2006 16:25
Re: smart code formatter
Regular expressions are very useful:
search pattern: ^(\t*)[ ]{3,5}
replace with: $1\t
Explanation:
linebeginning followed by arbitrary number of tabs followed by 3-5 spaces and
replaced by preveoiusly found tabs + one tab replacing 3-5 spaces.
search and replace several times with notepad++
Spaces converted to Tabs+Spaces
5S -> 1
3S -> 1
4S -> 1
2S -> 2S
6S -> 1T+1S
8S -> 2T
search pattern: ^(\t*)[ ]{3,5}
replace with: $1\t
Explanation:
linebeginning followed by arbitrary number of tabs followed by 3-5 spaces and
replaced by preveoiusly found tabs + one tab replacing 3-5 spaces.
search and replace several times with notepad++
Spaces converted to Tabs+Spaces
5S -> 1
3S -> 1
4S -> 1
2S -> 2S
6S -> 1T+1S
8S -> 2T
Re: smart code formatter
@RockTheSchock
thank you
thank you
Re: smart code formatter
Geany has a feature to replace tabs by spaces and vice versa, asking for the tab width before operation. It also supports addaption of line ends. Find the features in the 'document' menu.
And it supports regular expressions for search/replace.
Regards
And it supports regular expressions for search/replace.
Regards
Re: smart code formatter
@TJF
thanks for the tip :-)
thanks for the tip :-)