- This topic has 5 replies, 2 voices, and was last updated 5 years, 3 months ago by Brian Fernandes.
-
AuthorPosts
-
waveywhiteParticipantHi,
Python as a very particular style in using spaces for indentation. In most languages I use tabs but to keep things “pythonic” our code style for python is spaces.
So, I need to be able to control the indentation method for Python separately, which I can’t do on codemix.
I have found a work around! If I install pydev, I can set the indentation style there for python files and codemix will honour it. However, the two extensions don’t play nicely together so you then have to uninstall pydev and codemix will continue with indenting with spaces.
But, it would be a lot better to support this setting out-of-the-box.
-D
Brian FernandesModeratorI believe with the release we put out a few hours ago, this should work out of the box 🙂
1) Ensure you have the latest release – if you go to Preferences > CodeMix, and check the CodeMix Version, it should be
CI 2019.8.21
– restart if you don’t see this, your update may have already been downloaded and will apply on restart.This version has a change that detects the indentation being used in the file, and so if your file uses spaces already, it should just work.
Even without taking the update, you can also go to Preferences > CodeMix > Editors and check that the
Tab Settings
value is set toDetect Indentation
.2) If this does not work, we can specify language specific settings for indentation.
Go to Preferences > CodeMix > Editors, and at the top of the Dialog, you will see a “notepad” like icon that allows you to open settings.json. Go ahead and open this file.
You can now add a python specific section within the
settings
property –"[python]": { "editor.insertSpaces": true, "editor.tabSize": 4 }
If you save the settings.json file and reopen your python editor, these settings should now take effect.
Please let us know if you manage to get this working, installing pydev is definitely not required!
Brian FernandesModeratorJust checking in – were you able to resolve your indentation issues with my earlier suggestions? We’d be happy to investigate further if still unresolved.
waveywhiteParticipantHi,
I think it’s resolved. I added in the settings property like so:
`{
“folders”: [
{
“path”: “…”
}
],
“settings”: {
“php.suggest.basic”: “false”,
“php.validate.executablePath”: “php”,
“php.executablePath”: “php”,
“[python]”: {
“editor.insertSpaces”: true,
“editor.tabSize”: 4
}
}
}
`
waveywhiteParticipantSorry, a further follow-up. Given python’s sensitivity to indentation – please could we have separate python formatting options exposed in the options dialogue?
Thanks,
-D
Brian FernandesModeratorwavey,
Thanks for the update, we’ll look into making those preferences easier to set.
I have a question about the detect indentations setting I mentioned earlier. Was this on for you, or did you try to turn it on? With it on, I was able to get by without custom settings for Python, as the editor detected the indentation settings in the Python file and continued to follow them. Would be really keen to know about this, as having it “just work”, without the user having to do anything at all would have been the best experience.
waveywhiteParticipantYes, it was on for me after the software upload. I also used the manual settings as you suggested and tried creating a new Python file (i.e. no indentation yet) and the indentation was correctly done as 4x spaces.
The auto mode seems to work great for editing existing files but there needs to be control for new files as well, I think.
-David.
Brian FernandesModeratorThe auto mode seems to work great for editing existing files but there needs to be control for new files as well, I think.
A very valid point.
Thank you for taking the time to write back, really appreciate that. Have a great weekend, David!
Brian.
-
AuthorPosts