This is an old post, but in case anyone else wants to beautify python, I will post my workaround. I also wanted to be able to "beautify" python, in accordance with the pep8 standards. Turns out there are a number of python tools that do just that. So I chose autopep8 (
https://pypi.python.org/pypi/autopep8/). I use the SE function
filter_command() to transform the current buffer using autopep8. (For some reason,
filter_command() is not documented in the SE help, so use at your own risk.) The macro I use is:
/**
* Runs autopep8 on the current buffer, then replaces the current file contents
* with the autopep8 version.
*/
_command void apply_autopep8() name_info(','VSARG2_REQUIRES_EDITORCTL)
{
_str pep8_path = get_env('VSPROJ_AUTOPEP8_PATH');
if (pep8_path == "")
{
_message_box('No path for autopep8. Set VSPROJ_AUTOPEP8_PATH');
return
}
_str autopep_settings = get_env('VSPROJ_AUTOPEP8');
if (p_LangId != "py")
{
_message_box('Not a python file');
return
}
_str command = pep8_path " " :+ autopep_settings :+ " -";
select_all()
filter_command(command);
deselect()
}
This requires that the
VSPROJ_AUTOPEP8_PATH environment variable contain the full path of the auopep8 executable, and the
VSPROJ_AUTOPEP8 environment variable contain any options for autopep8 (it may be empty.) You can set these environment variables on a per-project basis in the "Project->Project Properties->Open" OS settings, or some other way. You could also replace them with hard coded values.
This macro does what I want, which is 'beautify' the whole file, but there is a lot of room for improvement. I hope others find it useful.