I am using Rope for my python auto-completion in vim. However, one thing that annoys me is that it auto-inserts its suggestions, making me unable to narrow down choices by continuing to type. This means that if I see my desired completion at the bottom of the list, I must move through the entire list with the down-arrow-key to select it.
My preferred usage would be seeing the list of suggested completions and be able to continue typing, which automatically removes items from the list that don't begin with my typed characters. An extra bonus would be the ability to then move down the list with the tab key.
In short, I would like the completion selection process to be like vim's omnicompletion when the options completeopt=longest,menu,menuone are set. Is this possible?
python-mode sets Vim's omnifunc to use Rope completion, which should do what you want.
Otherwise, you could check out this rope-omni plugin.
rope-omni plugin has been merged into the standard ropevim in this commit. And yes, https://github.com/python-rope/ is now the official home of all rope projects.
Related
I am new to spf13-vim configuration. I have a basic problem; for example, when I am writing a python script, if I type "for" in vim console, I could see:
1 for item in <`2:items`>:
2 <`0`>
Then I can type any variable on "item", but I couldn't figure out how to jump to the next item, "<2:items>". How could I do that?
The direct answer to your question is: press Tab.
This feature is most certainly not provided by spf13 itself: it is provided by a snippet-expansion plugin that comes with spf13. Maybe it's SnipMate? Maybe it's UltiSnips? Maybe another one? Who even knows? You could simply look up up the documentation of that plugin but you can't, because you don't know what plugins you have.
Well, you are supposed to know what the plugins you add to your config that you manage yourself do and do not. But you don't, because you gave away that responsibility to someone else and you end up with a black box that contains and does things you have no idea about.
And the best part is that you don't even ask for help to the author/maintainer of that crappy distribution. They lured you into installing their stuff and giving control up, they are the ones who should help their poor, misled, users.
If you are serious about using Vim, drop spf13 immediately and take care of your configuration yourself.
If you don't care about doing things the right way, use another editor.
Press Ctrl+k to jump to the next item.
In Sublime Text I used small and handy MiniPy plugin.
It evaluates each expression in multi-cursor selection and replaces the selection with the result.
For example, I have selected these lines in ST:
1+1
2+1
3+1
When I press <c-s-x> I get:
2
3
4
I use vim-multiple-cursors plugin, but can't see how to make this work.
So my question is how can I evaluate multi-cursor selections in vim, preferably through Python.
Please note that multi-cursor selection doesn't have to be on a separate lines.
I would go with bc, too, but what about a pure Vim command?
:1,3norm c$^R=^R"^M
^R is obtained with <C-v><C-r> and ^M with <C-v><CR>.
As for your question, this will depend on what that plugin does with the "selected" text.
Since Vim doesn't provide non-contiguous selection there's no ready made way to get the content of the multiple "selections" (they are not actual selections) made with that plugin.
You will need that plugin to export the selected text in one way or another and I'm afraid this goes a bit beyond the scope of SO.
I'd suggest you get in touch with the author of that plugin and see if he is able to help you.
That said, you might be interested by Pipe2Eval.
Where is the option to disable the spell check on the strings for the PyCharm IDE?
I hate the jagged line under my comments and strings.
Go to File -> Settings -> Editor -> Inspections. Expand the list under Spelling in the middle window and uncheck the option Typo.
However, practically most of the jagged line is caused by violations of the PEP 8 coding style. If you would like to disable this option too, in the same window, expand the list under Python and uncheck the option PEP 8 coding style violation.
In the latest version of PyCharm it appears as ProofReading:
You can disable spellchecking for specific code section by commenting # noinspection SpellCheckingInspection above it.
See https://www.jetbrains.com/help/pycharm/spellchecking.html
PyCharm does not check the syntax inside strings and comments. It checks spelling.
You can find the settings of the spell-checker under the Settings... page. There is a Spelling page inside Project Settings. Inside this page, at the bottom of the Dictionaries tab you can enable/disable dictionaries. If you don't want spell checking simply disable all of them.
Note that it is possible to add custom words in the spell checker, or, if you already have a dictionary on your computer, you can add it. This can turn out useful if you want to spell check different languages (for example Italian).
In particular if you are using a Linux system and you have installed the Italian language pack, you probably have the Italian dictionary under: /usr/share/dict/italian.
You can add the /usr/share/dict directory to the directories searched for dictionaries and enable the italian dictionary.
It seems like PyCharm only checks files with the .dic extension. If you want to use /usr/share/dict/italian you should probably either copy it into an other directory renaming it italian.dic or you could create a symbolic link.
In my opinion the best option is to disable typo checks only for code. This way green lines under variable/method/class names and strings disappear, but PyCharm still controls comments to avoid misspellings, so You have both nice compact code and fully understandable docs.
I don't exactly know since which PyCharm version this option is accessible, but for sure in revision 2020.2 if You highlight a Typo in Settings > Editor > Inspections > Proofreading there are three additional options in the right panel - just uncheck Process code.
In the newer version of PyCharm, go to Preferences -> Editor -> Inspections -> Spelling.
You can also add particular typo word to PyCharm dictionary by pressing Alt + Enter this word and select Save [typo word] to dictionary. Sometimes this is best choice for me.
For single line you can use the # noqa at the end of the line and it will suppress spelling inspections (the squiggly green line).
GOOFY_API_USERNAME_THING = "LAksdfallae##lkdaslekserlse#lsese" # noqa
I'm using PyCharm 2021.3.2
I found how to disable typos only in string literals in official documentation by disabling process literals, but it doesn't work for me (maybe it's a bug, that will be fixed in the future).
Settings->Proofreading->Typo
I'm new to eclipse. One thing I notice about eclipse+PyDev is that it give me warning if the indentation is not in multiple of 4 space. That is fine because I could use "reindent.py" to just reindent it. And I manage to setup it as the external tools. But the problem is, when I use it, (using Run->Externaltools->reindent) it would modify the code in the background, so after that, it would pop up saying that the source code has been modified (duh!) would you like to to reload the file? (duh again!) So, my question is, is there a way to pipe the current selection of the source code through reindent (it uses standard input/output when given no argument) and then replace the selection with reindent standard output automatically. Thanks!
Check in the preferences > general > workspace if you have 'refresh on access' and 'refresh with native hooks' both checked (that may solve your problem).
Another thing to check is in your external tool configuration: it has a 'refresh' tab, where you can choose to refresh the selected resource upon completion.
Another thing... if you have things just in a different indent (say 2 spaces), you can simply replace all 2 spaces by 4 spaces in the find instead of going through reindent...
When you run reindent.py as an external tool, you modify the whole file that contains the source code, not the current selection in your editor. But according to PEP 8 you should not mix tabs and spaces, so this might actually be what you want. In that case just click ok to reload the file and find that it worked.
In the settings you find some options under Window->Preferences->PyDev->Editor
There you can activate automatic replacement of a tabs with spaces when typing. Also you can choose that PyDev assumes tab-spacing for files that contain tabs.
You might want to read this:
How to integrate pep8.py in Eclipse?
When you activate Window->Preferences->PyDeV->Editor->Code Analysis->pep8.py you can generate a warning for every line, that conflicts with the convention.
I've been all over the web trying to find a way to get VIM to have code completion similar to PyDev. It doesn't seem like it is possible!
-I have tried to use the omnicompletion suggested at this link: http://blog.dispatched.ch/2009/05/24/vim-as-python-ide/ .
-I have tried several addons to alleviate the problem, none work.
The "omnicomplete" functionality is NOT what I am looking for. It just takes all the words in the file you are working on and uses those to try and complete what I am doing. For example if I wrote:
import numpy
a_single_array = range(100)
np.a#[then I hit cntrl+n to code complete]
It would spit out "a_single_array" as a possible completion -- but that is absurd! That is not a valid completion for "numpy.a ..."
What is the issue here? All the addon would have to do is run a dir(work you want to find) from the folder you are in and then filter the output! This cannot be that difficult! (I suppose you would also have to read the file you are currently editing and filter that as well to take note of name changes... but that's pretty much it!)
Speaking of how easy it would be... if there isn't anything already made, I was thinking of writing the script myself! Any guides on how to do THAT?
No, the omni completion functionality is EXACTLY what you are looking for.
You are using <C-n> instead of <C-x><C-o>:
type <C-n> & <C-p> to complete with words from the buffer (after and before the cursor respectively)
type <C-x><C-o> to complete method/properties names
It's specifically explained in the article you linked:
In V7, VIM introduced omni completion – given it is configured to recognize Python (if not, this feature is only a plugin away) Ctrl+x Ctrl+o opens a drop down dialog like any other IDE – even the whole Pydoc gets to be displayed in a split window.
Ctrln is insert-completion.
Ctrlx Ctrlo is omni-completion.
I remap omnicompletion to CtrlSpace:
inoremap <C-Space> <C-x><C-o>
You could also try SuperTab.
I have no idea about the various completion options for Python in Vim. But if you want to roll your own you'd be well advised to study and modify one of the existing ones, like this:
http://www.vim.org/scripts/script.php?script_id=1542
Also, if all your omnicompletion is doing is listing words in current file then you don't have it set up properly for Python-specific completion. . . . Not sure how good the specialized Python completion systems get, but they certainly does compete based on Python units external to your current file. . . .