Edit macro in Notepad++ tab issue

Need help, or want to share a macro? Post here!
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Post Reply
PeterII
Posts: 21
Joined: Sat Aug 14, 2021 8:53 am

Edit macro in Notepad++ tab issue

Post by PeterII »

Hi,

I have an annoying issue. When I edit the macro in notepad++, for some odd reason, all the characters are correctly shown in Freecad macro editor, except tab. It is translated into 4 spaces when opened in Freecad editor. Has anyone had a similar issue? And is there a way to solve it?

notepad ++ tab
notepad_tab.png
notepad_tab.png (24.07 KiB) Viewed 1745 times
freecad tab
freecad_tab.png
freecad_tab.png (39.79 KiB) Viewed 1745 times
Kind regards,
Peter Korenčan
Attachments
n.FCMacro
(236 Bytes) Downloaded 16 times
Kind regards,
Peter
mario52
Veteran
Posts: 4672
Joined: Wed May 16, 2012 2:13 pm

Re: Edit macro in Notepad++ tab issue

Post by mario52 »

Hi

FreeCAD:
Menu > Edit > preference > General > Editor > Indentation Space or Tabs

Notepad ++:
Menu > edition > Traitement des espaces

the best use space

mario
Maybe you need a special feature, go into Macros_recipes and Code_snippets, Topological_data_scripting.
My macros on Gist.github here complete macros Wiki and forum.
TheMarkster
Veteran
Posts: 5505
Joined: Thu Apr 05, 2018 1:53 am

Re: Edit macro in Notepad++ tab issue

Post by TheMarkster »

You don't want tabs in your python code, or at least you don't want to mix tabs and spaces. Everybody seems to be using spaces for python code in FreeCAD, so it's better to just use the 4 spaces. Mixing was okay with python2, but no longer works with python3.
User avatar
onekk
Veteran
Posts: 6098
Joined: Sat Jan 17, 2015 7:48 am
Contact:

Re: Edit macro in Notepad++ tab issue

Post by onekk »

Tabs in Python are not very accepted, in fact all the guides to the language will advice to use spaces.

Edit:

from PEP8

Tabs or Spaces?

Spaces are the preferred indentation method.

Tabs should be used solely to remain consistent with code that is already indented with tabs.

Python disallows mixing tabs and spaces for indentation.
Why? "tabs stops" could have different lengths, so the most simple thing is to use 4 space per indent level.

It is consistent across OS and between editors.

Other thing, are avoid to have spaces at the end of the line and avoid having empty line with only spaces, so it is better to activate also "Show non printable characters" or whatever options your editor have to show spaces, usually as little grey points.

All editors have such option and is very useful.

Happy coding with Python and FreeCAD.

Regards

Carlo D.
Last edited by onekk on Sat Jan 22, 2022 9:57 am, edited 1 time in total.
GitHub page: https://github.com/onekk/freecad-doc.
- In deep articles on FreeCAD.
- Learning how to model with scripting.
- Various other stuffs.

Blog: https://okkmkblog.wordpress.com/
openBrain
Veteran
Posts: 9031
Joined: Fri Nov 09, 2018 5:38 pm
Contact:

Re: Edit macro in Notepad++ tab issue

Post by openBrain »

mario52
Veteran
Posts: 4672
Joined: Wed May 16, 2012 2:13 pm

Re: Edit macro in Notepad++ tab issue

Post by mario52 »

Hi

it is interesting to activate the spaces by default instead of tab in the preference Editor > Indentation

mario
Maybe you need a special feature, go into Macros_recipes and Code_snippets, Topological_data_scripting.
My macros on Gist.github here complete macros Wiki and forum.
PeterII
Posts: 21
Joined: Sat Aug 14, 2021 8:53 am

Re: Edit macro in Notepad++ tab issue

Post by PeterII »

Thanks guys. I changed the setting in notepad++ now it works with tabs. I like it better.

Regards,
Peter
Kind regards,
Peter
Post Reply