Not long ago, I started commenting a lot of code in python, the problem is that vs code does not offer me to reduce the comment.
I have tried single line comments and group comments but same issue..
python single line comment
python multiline program
In other languages for example C.. it offers me in the bar a button to collapse
example in C
How can comment collapsing be enabled in VS?
I tried it. I think vscode itself provides this function, but I don't know why it doesn't work for you.
As can be seen from the figure, multiline annotations can be folded.
Of course, there is no solution for your situation. We can add #region before the content, add #endregion after it.
Related
The word "file" in python is not a keyword, but my Vim highlights it as if it were. Can someone suggest a fix and explain this strange behaviour? It keeps messing with me. It bothers me every time I look at it.
Extra info
I think I use regular Vim—I haven't tinkered with my .vimrc much, certainly not with the syntax highlighting.
Many builtins were removed in the Python 2 to 3 transition. file is one of them. Lots of syntax highlighters still highlight them. Now that Python 2 is no longer supported, maintainers may be willing to remove them from the lists, so you can try opening an issue if it bothers you.
I have a working version of JEDI with Emacs 24.3 on osx. The autocomplete feature is wonderful, except for when I want to comment things out! I frequently comment/uncomment portions of my code and was hoping there was a way to prevent JEDI's auto completion from coming up when I type #. Any advice or thoughts would be greatly appreciated!
edit: When I go to comment multiple lines I enter in # typically followed by DownArrow and LeftArrow, but what usually happens with JEDI enabled is this dialog pops up preventing me from moving to the following line until I make a selection:
You can try to use company-jedi for your python completion. This package doesn't have this problem.
One way to get around this issue would be to select the lines (region) you would like to comment out and hit M-;. This runs the command comment-dwim which comments out the selected region (or uncomments it, if it is currently commented out).
When used in conjunction with e.g. mark-lines which allows you to select the current line with a single key stroke, this makes for a really fast way of (un)commenting portions of your code, even if they span just one or two lines.
emacs-jedi dev here. If emacs-jedi works as you describe, then that's a bug.
But I cannot say what is wrong from the limited information I have. So, just general directions:
First, always try to reproduce the misbehavior in a clean Emacs setting, described here http://tkf.github.io/emacs-jedi/latest/#quick-try
This helps you to find out if your setting is wrong or if it is actually a bug in emacs-jedi.
Give the output of M-x jedi:show-version-info. http://tkf.github.io/emacs-jedi/latest/#jedi:show-version-info
This helps people diagnosing the problem.
This is a guess from your screenshot but it seems that you have old version of popup.el. So maybe auto-complete.el could be old one if you install them at the same time. If you don't see the problem in the clean Emacs (step 1. I mentioned above) which installs newest libraries, then updating them could solve the problem.
Update
So, I found a way to reproduce the behavior which is close to what you mentioned: https://github.com/tkf/emacs-jedi/issues/147
But as I wrote in the issue, I think it is a rare case. If you find a case which could happen very frequently, then let me know.
Is there any way to enable code hiding (hides the details of a class or a function just shows the definition) and line numbers in IDLE ?
Don't think so. It was discussed briefly on the mailing lists, but I don't believe anything's come out of it since.
If you're interested in code folding, look into slightly more powerful editors - Geany (GTK) and Sublime Text both support code folding.
A code/line folding feature was asked before in that Python Issue. It was closed and rejected but with good reasons.
If you know this features of IDLE you maybe do not need code folding anymore.
Module Browser:
To get an outline view of a file's classes and functions, use File => Module Browser (ALT+C).
Code Context:
To get a dynamic view of nested compound statement headers with Options => Code Context.
I am using the excellent "Learn Python The Hard Way" tutorials and i am wondering does anyone know if its possible to create block comments in it? I note from a similar question here that it does not seem to be possible in Python but that some editors have implemented methods to do it.
EDIT
I have edited the above question to provide more detail and to use the term "block comment" insted of "block quote"
Thanks
This is a duplicate question: Commenting/Uncommenting a block of Python code in TextWrangler
However, I recommend you not bother with those 9 steps and instead just download sublime text 2.
It is an excellent editor for Python (I believe that's the language its written in, in fact.) and you can accomplish what you're looking for by simply highlighting the code block and using the comment/uncomment keyboard shortcut: Ctrl+Shift+/
In textwrangler on a mac, this worked for me. Highlight the text you want to comment out. Hold down the Command Key and hit /.
Coming from Perl I've been used to hitting C-c t to reformat my code according to pre-defined Perl::Tidy rules. Now, with Python I'm astonished to learn that there is nothing that even remotely resembles the power of Perl::Tidy. PythonTidy 1.20 looks almost appropriate, but barfed at first mis-aligned line ("unexpected indent").
In particular, I'm looking for the following:
Put PEP-8 into use as far as possible (the following items are essentially derivations of this one)
Convert indentation tabs to spaces
Remove trailing spaces
Break up code according to the predefined line-length as far as it goes (Eclipse-style string splitting and splitting method chains)
Normalize whitespace around
(bonus feature, optional) Re-format code including indentation.
Right now, I'm going throught someone else's code and correct everything pep8 and pyflakes tell me, which is mostly "remove trailing space" and "insert additional blank line". While I know that re-indentation is not trivial in Python (even though it should be possible just by going through the code and remembering the indentation), other features seem easy enough that I can't believe nobody has implemented this before.
Any recommendations?
Update: I'm going to take a deeper look at PythonTidy, since it seems to go into the right direction. Maybe I can find out why it barfs at me.
There is a reindent.py script distributed with python in the scripts directory.
untabify.py (Tools/scripts/untabify.py from the root directory of a Python source distribution) should fix the tabs, which may be what's stopping Python Tidy from doing the rest of the work.
Have you tried creating a wrapper around pythontidy? There's one for the sublime editor here.
Also, does pythontidy break up long lines properly for you? When I have a long line that ends in a tuple, it creates a new line for every entry in the tuple, instead of using Python's implied line continuation inside parentheses, brackets and braces as suggested by PEP-8.
I have used autopep8 for this purpose and found it handy.