I like the autocomplete feature of PyCharm in most cases. But sometimes it just suggests nonsense.
For example if I want to name a method one it renames it to __round__(self, n=None)
How can I skip the suggestion in this case? I didn't find the correct keyword in the PyCharm documentation.
If I write eg. def one I would prefer the following behaviour:
tab or/and enter --> accept suggestion
shift + ctrl + enter --> complete statement to def one(self):
Maybe you can tap space when the autocomplete suggestion appears and then delete the space instead of using Mouse.
It works for the first time pycharm shows suggestion, but if you use ctrl+space for suggstion and then tapping space, it will autocomplete default code suggestion.
Anyway, space is enough for preventing coding interruption
Go to File -> Settings -> Editor -> General -> Code Completion
UNCHECK - Insert selected suggestion by pressing space, dot, or other context-dependent keys
Now, you can use SPACE to skip.
TAB or RETURN will insert.
Related
How to get PyCharm to show the keyword arguments while coding, like the options you can pick from? I can get VSCode to show this normally, but I just can't figure out how to get PyCharm to do it. You'll see the difference in the screenshots. One is from PyCharm and the other one is from VSCode
If you start a new project in PyCharm, add a .py file and entire the following code:
import os
os.chdir()
And you position the cursor between the two parentheses while typing, or when you press Ctrl+P in that position, PyCharm will show a hint saying "path: int | str | bytes | PathLike[str] | PathLike[bytes]", like this:
If you're just looking for the autocomplete, instead of the type hints, similarly ensure you're typing something that could be completed and PyCharm wil show type hints you can navigate with arrow keys (or can just complete by hitting Enter).
Note that you can cause PyCharm to show it again by hitting Ctrl+Space.
Mind you, if you type something that has no logical completion (i.e. nothing starts with the string you've written so far), there is no autocompletion, and so none is shown - instead PyCharm will show a small message in its place saying 'no suggestions'.
YouCompleteMe is a lovely tool for autocompletion in vim. It also shows the docstring of the 'hovered' autocomplete candidate, which is a very useful tool for me. This preview is sadly closed as soon as one confirms the candidate, e.g. by opening parentheses.
Example:
First Docstring is shown:
Typing a parenthesis will kill the docstring though:
Now i would love to keep the docstring while my 'cursor' is in the parentheses of whatever i just autocompletion for (to be detailed: obviously the docstring of the innermost parentheses, if they are nested).
Can this be done, and if yes, how?
Thank you so much in advance,
LJKS
Add below to your vimrc
let g:ycm_autoclose_preview_window_after_completion = 0
or Default.
The optional g:ycm_autoclose_preview_window_after_completion is 0 by default.
I think this will help you out:
let g:ycm_autoclose_preview_window_after_completion = 0 " default
let g:ycm_autoclose_preview_window_after_insertion = 1
ycm_autoclose_preview_window_after_insertion:
When this option is set to 1, YCM will auto-close the preview window after the user leaves insert mode. This option is irrelevant if g:ycm_autoclose_preview_window_after_completion is set or if no preview window is triggered.
Default: 0
Problem is when jedi-vim finds only one match for autocomplete it automatically insert this match. I need somehow disable this feature.
What I've already tried:
let g:jedi#smart_auto_mappings = 0, but it only disables auto from ... import ... insertion;
let g:jedi#popup_on_dot = 0, but it also disable popup on dot options (so I need to type <C-space> to see it).
let g:jedi#popup_select_first = 0 also won't help as it only disable first match selection in popup menu, but not prevent auto insertion of only match.
Also I don't have any other autocomplete plugins installed. If it helps, this is my .vimrc file
Is there some way to disable auto insert of only matching feature but keep popup on dot?
P.S. you can recreate this behavior with this example:
class A(InvisibleClass):
i = 1
Then when you type A and press dot i will be inserted automatically.
This behavior is controlled by Vim's completeopt option. jedi-vim sets it to menuone,longest,preview since you haven't changed it (starting here). You should explicitly set it in your .vimrc to include noinsert.
Vim's docs say that noinsert has no effect if longest is present, but that doesn't match the behavior I'm actually seeing (NVIM 0.0.0-alpha+201510011522 (compiled Oct 5 2015 14:55:04)).
I'm sure there is an easy fix for this, but I've scoured the preferences and haven't been able to find an option with an appropriate sounding name.
Here's a simple example, the top line isn't in the code, but there to illustrate every 4th character position:
# # # # # # # #
a = 2 # something two
b = "ab" # something else foo
Between "something" and "two" I hit <tab> twice, between "something else" and "foo" I hit <tab> twice.
My expectation is that using tab inside a comment would insert the necessary spaces to get to the next tabstop (the way tab outside of a comment works) Instead, pressing tab always inserts exactly 4 spaces, regardless of the column you're currently in.
This doesn't happen in Eclipse inside a Java project, which leaves me to believe it's a PyDev thing.
Just to be clear, I expected that hitting tab twice on the first line and once in the second would produce:
# # # # # # # #
a = 2 # something two
b = "ab" # something else foo
Thanks in advance for what is almost definitely a very simple fix.
P.S. I was hesitant with tagging this with Python, if there's a user with edit privileges wants to untag it, I wouldn't be offended in the least.
This is really expected in PyDev right now.
As a note if someone would want to implement that, the related place is:
org.python.pydev.editor.autoedit.PyAutoIndentStrategy.customizeDocumentCommand -- with tests at org.python.pydev.editor.PyAutoIndentStrategyTest.
This currently enters the case where "if (!contentType.equals(ParsingUtils.PY_DEFAULT))" where we don't handle expected tab-stops as we'd on code partitions (i.e.: org.python.pydev.editor.autoedit.PyAutoIndentStrategy.handleTab).
Is it possible to change the way PyCharm adds the hash # when using the keyboard shortcut to comment a line? (default CTRL+/)
I'd like the # to be at column 1 rather than at the indent level. Also, the cursor is moved down a line after the keyboard shortcut and I'd rather it stay on the same line.
Currently:
def foo():
my_uncommented_line
# commented_with_keyboard_shortcut
var = "and now the cursor is at the start of this line"
What I'd like:
def foo():
my_uncommented_line
# commented_with_keyboard_shortcut
var = "cursor stays on the previous line"
I'm currently searching around the JetBrains plugin repo for something that does this, but no luck thus far.
I know that this doesn't follow PEP8. I'd like to be able to make this change so that I can be consistent with the rest of the project:
Some other good reasons to ignore a particular guideline:
2. To be consistent with surrounding code that also breaks [the guideline].
The most you can do is alter the style: