Can't control indentation method for Python separately to other languages

This topic contains 7 replies, has 2 voices, and was last updated by  Brian Fernandes 2 weeks, 3 days ago.

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #621242 Reply

    waveywhite
    Participant

    Hi,

    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

    #621248 Reply

    Brian Fernandes
    Moderator

    I 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 to Detect 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 –

    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!

    #621528 Reply

    Brian Fernandes
    Moderator

    Just checking in – were you able to resolve your indentation issues with my earlier suggestions? We’d be happy to investigate further if still unresolved.

    #622145 Reply

    waveywhite
    Participant

    Hi,

    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
    }
    }
    }

    #622146 Reply

    waveywhite
    Participant

    Sorry, 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

    #622244 Reply

    Brian Fernandes
    Moderator

    wavey,

    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.

    #622256 Reply

    waveywhite
    Participant

    Yes, 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.

    #622265 Reply

    Brian Fernandes
    Moderator

    The 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.

Viewing 8 posts - 1 through 8 (of 8 total)
Reply To: Can't control indentation method for Python separately to other languages

You must be logged in to post in the forum log in