Registered Member
|
I am using Kdevelop, but the problem is the same in pure Kate. Editing a Python file, e.g.
and doing Ctrl-d used to produce:
which is easy to read/remove the comment symbol/have nested comments. But now it seems to produce:
which is much less clear (at least to me). Is there a way to get back to the old behaviour? Thanks |
Registered Member
|
I just stumbled on the same problem and wanted to know whether there is a solution. Using kate 16.08.3 (current debian stable).
|
Registered Member
|
Any solution yet? Thanks! Martin
|
Registered Member
|
Hello, I found how to change this behavior. The symbol and position of the comment are defined by syntax definition files used by KSyntaxHighlighting. You can see the syntax definition file for python under /data/syntax in the repository for KSyntaxHighlighting. The exact part of the file where the comment behavior is defined is at the end of the file in the <comment> element. For the python file, the element looks like this:
The string start defines the comment string used to comment python code, in this case it is "#" and the position part defines where the comment string should be put. For python by default the position is "afterwhitespace" which means that the comment is inserted after the white space. If you want the comments to appear at start of the line you can remove the position="afterwhitespace" part. You can then put the xml file in $HOME/.local/share/org.kde.syntax-highlighting/syntax/. Then kate should be able to insert comments at the start of the line instead of after the white space. Here is more information about where to put the xml file in other windows and macOS and more information about KSyntaxHighlighting. I am not sure why the default comment behavior for python is done such that it results in a style warning by flake8 (Block comment should start with '# ' (E265)). I think it would be better if the position="afterwhitespace" is removed for the python syntax definition file or if start="#" is changed to start="# " so that comments add a space between # and the code. I hope this is useful for others. |
Global Moderator
|
If you think this behaviour is desirable for everyone, consider submitting your change as a patch on invent.kde.org!
I'm working on the KDevelop IDE.
|
Registered users: bartoloni, Bing [Bot], Google [Bot], Sogou [Bot], Yahoo [Bot]