Questions tagged [filetype-python]

Configuring and using vi/vim to edit python code. For scripting vim using python, use the /vimscript-python tag.

Filter by
Sorted by
Tagged with
0
votes
1answer
70 views

Python Language Server Protocol with virtual environment

Can anyone help me get things like "Go to definition" working with Neovim and Python virtual environments? My setup currently uses a specific virtual environment for Neovim (as recommended by :...
1
vote
1answer
48 views

getting vim to autocomplete python methods

I am coming from statically types languages, but I will have to be using python for the next few years and I want to get my setup as smooth as possible. Right now I am using vim-jedi, and deoplete-...
0
votes
0answers
471 views

Correct way to setup python version for coc

I want to set PYTHONPATH and python interpreter according to projects I am working on. I am working both on projects involving python 2.0, and ones involving python 3.0. There is the concept of ...
2
votes
0answers
145 views

How do I setup Mypy with Neomake

I'm trying to use Mypy with Neomake, but without success. I am currently using flake8 with Neomake, and it works seamlessly, e.g.: def foo(bar): return 1 foo(1) > E305 expected 2 blank lines ...
1
vote
1answer
61 views

On startup: ImportError: No module named ropevim

When starting nvim, my :messages contains: Error detected while processing function LoadRope[4]..provider#python#Call: line 18: Traceback (most recent call last): File "<string>", line 1, ...
0
votes
1answer
24 views

Vim Jedi Plugin — Add .sage filetype

,g$$$$$$$$$$$$$$$P. OS: Debian 9.9 stretch ,g$$P"" """Y$$.". Kernel: x86_64 Linux 4.19.0-0.bpo.4-amd64 ,$$P' `$$$. Uptime: 3h 17m ',$$P ,ggs. `$$...
2
votes
1answer
78 views

Documentation for python

I've been looking around for a while now but I couldn't find a proper answer. I would like to access python documentation from Vim. I know that some plugins exist (like this one: https://github.com/...
1
vote
1answer
313 views

vim python syntax not working (Partly)

Vim only seems to highlight comments, numbers, and imported modules. So function calls, attributes, etc are all non-highlighted. I have 'syntax on' and 'filetype plugin indent on' in my vimrc. syntax ...
0
votes
0answers
18 views

Vim Jedi Work for Python2 Functions but Not Python3 Functions

I installed Jedi-Vim with Vim-Plug. I also ran pip3 install jedi and pip install jedi. The plugin works for python2 functions such as raw_input()., however, when I type in input()., vim gives me the ...
0
votes
0answers
35 views

tabstop doesnt work by default in python files [duplicate]

I have set up set tabstop=2 set lcs=tab>.,trail=. in .vimrc when i open .txt files, tabs are displayed as >. however when i open a .py file, tabs are displayed as >......... I ...
2
votes
1answer
205 views

How to highlight unused Python imports in VIM

I want to highlight unused Python imports as Python syntax errors. For example, I sometimes forget to remove some packages used for debugging such as time, ipdb. It would be great to see warnings or ...
1
vote
0answers
128 views

vim syntax for python call and keyword arguments: issues with built-in keyword

I am trying to come up with a vim syntax for python function call, e.g. foo(notarg==0, arg2, kwarg='a', kwarg2='b') dict(a=1, b=2, c=3) where we want to highlight (i) function name foo, dict (ii) ...
3
votes
1answer
5k views

Python debugging

Is it possible to debug Python scripts line by line using :Termdebug? :help termdebug-customizing says, that you need a debugger that is "fully compatible with gdb". Is there a debugger for Python ...
1
vote
1answer
60 views

C++: different auto-indentation for function protoypes versus continuation lines

I have the following options setup for C++ and Python development in vim: autocmd BufEnter *.cpp setlocal tabstop=4 shiftwidth=4 softtabstop=4 textwidth=80 noexpandtab cindent cinoptions=:0,l1,t0,g0,(...
1
vote
1answer
1k views

How do I configure syntastic to use Python3 in Ubuntu?

The following code shows invalid syntax. I assume syntastic is looking at Python2 for syntax-checking. I need it to look at Python3 instead. def x(): x = 42 def y(): nonlocal x x = 8 ...
1
vote
0answers
102 views

Issue when creating files using python in vim

When writing or appending files using python inside vim, new files are not being created and existing files are not being changed. Creating and appending files in python script and atom text editor ...
3
votes
1answer
311 views

Plugin for vim that auto indents after a : when editing python?

Is there a way to indent automatcally after typing a : when editing python in vim? I works that way in CodeMirror and I found it nice; so I wondered if vim has that capability?
4
votes
0answers
588 views

vim compiled with python3 but python3 omni-completion does not work

It used to work when I used python2, but now I can't use ^X^O to complete function names. I do have vim with -python and +python3 (on Ubuntu 16.04), but here is the error I get when trying Ctrl-X ...
2
votes
1answer
111 views

What is a good debug front end plugin

I would like to use vim to write python codes, it is good to use python-mode plugin. However, I have to debug with pdb in the terminal, which is quite inconvenient since I have no way to view the ...
2
votes
1answer
394 views

Getting vim with yapf to work with anaconda environments

I'm trying to figure out how to get yapf to use my current conda environment when resolving imports. Basically, I just see a ton of the following errors: physics.py|6 col 1 error| [import-error] ...
1
vote
1answer
71 views

Automatically update import path if file is moved in Vim

Is there a way in which if you move file A to another location and there are other files that have imported file A, the import path will change accordingly in Vim? PyCharm has this and I was ...
0
votes
3answers
338 views

Show python help() inside vim

I'm new to Vim and would like to know is there a plugin, which allows you to call Python help() function on the word under cursor and shows returned text in the splitter buffer?
0
votes
2answers
724 views

Tabs on Vim not interpreted as tabs inside python

I have created this tab-separated file with Vim: #id #comma separated values 0 d1,d2,cu 1 iii vvv,iii ccc,mmm ccc The function I use to read the file: def read_file(filename): f = open(...
4
votes
2answers
2k views

Vim python debugger

I'm using vim for python scripting and currently approaching jedi-vim for autocomplete, navigation and refactoring. But it would be nice to have some ide-like debugging facilities. Is there some ...
5
votes
1answer
2k views

How can I highlight all function names in Python files?

I try to make python.vim color similar to material theme (sublime text 3), see pictures: https://imgur.com/a/wOgH7 expected is material theme and current is mine. You may noticed that all method, ...
6
votes
1answer
3k views

Why is “set noexpandtab” in my ~/.vimrc ignored when I open a file? [duplicate]

I'm using Mac OS X 10.12 and I have set noexpandtab in my ~/.vimrc There are 2 different behaviors : $ vim file.py If run Vim (8.0) to open one file and type :set expandtab?, it says expandtab $ ...
0
votes
1answer
224 views

Strange Fold Info Showing in Gutter

It's only happening in one of my .py files when opened with vim, I am getting some kind of fold info in the gutter that shouldn't be there - made up of the characters '2', '-' and '|'. I disabled ...
4
votes
1answer
124 views

Is there a % equivalent for editing python code?

When I edit C-style languages, I can use % to jump between pairs of square brackets, braces, and parenthesis. If there an equivalent between for, while, def, if and the last indented line for the ...
1
vote
1answer
466 views

Closing error window

When I run yapf on my code, an error page appears, rightly showing the error I have in the code. How on earth do I close this window and go back to my code? :lclose doesn't work. :close closed the ...
0
votes
1answer
6k views

Automatic whitespace in python

I'm a novice in Vim and configuring it for writing python scripts comfortably. Is the a way to automatically put four spaces after I jump onto the first line of while True: loop ?
2
votes
1answer
408 views

How can I remove a syntax keyword?

In Python3, file is no longer a builtin. It's just a plain ol' name that isn't even associated with anything until you do. But all the syntax files that I've used have it as a builtin. Is there a ...
1
vote
1answer
664 views

Python: Strange auto indent behavior after function call

Can anyone explain to me why when writing python code, vim is auto indenting when entering carriage return after function call ie. f.write(name, r) Before writing(:w) file import bs4 as bs import ...
1
vote
1answer
483 views

Highlight all imported modules in python

For example import numpy as np import matplotlib.pyplot as plt x = np.array([-1, 0, 1]) y = np.abs(x) plt.plot(x, y) plt.show() Is there a way to highlight all the occurrences of np and plt?
0
votes
1answer
569 views

Mapping to execute python file only works on first buffer

Aloha, I took the plunge to start using vim as my main editor. I'm a week in, and beginning to see the beauty of it. It's now the only editor I use already. Anyhoot - I found a very useful mapping ...
3
votes
3answers
567 views

Test python function from within editor

I am writing python 3 code from within vim. There is a function within my file like this: def seconds_to_text(seconds): return str(datetime.timedelta(seconds=seconds)) Is there a way for me to ...
7
votes
1answer
886 views

How can I change the highlighting of python class name?

How can I define a syntax to highlight the python class name MyClass in vim? class MyClass(object): ...... Vim has already highlighted the class name. However, it seemingly highlights it with ...
2
votes
1answer
460 views

How to disable automatic unindent of comments in Python?

I start vanilla vim8 $ vim -u NONE with these settings: :set ft=python :set smartindent :set cinkeys-=0# When I enter in insertion mode the following: Hello # The # is automatically ...
3
votes
0answers
2k views

Generating tags for python that follow imports [closed]

I'd like to be able to conveniently navigate to the file where a Python value (function/class/constant) is defined. Most of the guides I can find for using ctags with Python suggest options that aren'...
7
votes
1answer
2k views

Python imports autocompletion

I'm trying to configure vim for python development. Right now I'm working on code autocompletion feature. I'm using YouCompleteMe plugin and it seems to be working great but only when I've already ...
11
votes
1answer
7k views

How can I fix “missing” syntax highlighting for Python keywords such as “self”?

I'm trying to fix syntax highlighting for python; my colors are different from those in screenshots of what it "should" look like in different vim color schemes. And you can see the difference in ...
3
votes
2answers
658 views

How to set the relative indent after breaking Python lines?

When I insert a line break inside a line of Python 3 code, the remaining part of the line is indented by two additional tab widths (2 time 4 spaces) in the next line. # Before example_function(...
7
votes
2answers
3k views

Vim doesn't use the correct indentation in Python files

I have encountered something that I have never seen before in Vim. While I was tentatively modifying some of the source code for software I've been planning to work on, I noticed vim was displaying ...
3
votes
3answers
422 views

Is it possible to add a specific text string in the beginning of creating a certain file type? [duplicate]

Just like the topic says; is it possible to add a certain text string in the beginning of a file if I create a certain file type? For example, if I create a random Python file with vim random.py. Can ...
4
votes
2answers
857 views

How to check the syntax of a file on the fly?

For those who might not know, Flycheck is a plugin which checks the syntax of the code you're writing on the fly, without forcing you to save the file. It does that by periodically saving the buffer ...
1
vote
0answers
551 views

How to use external python modules with NeoComplete?

After trying out many auto-completion engines for Vim, NeoComplete combined with Jedi seems like a good choice for python development. However, I can't get it to use external libraries like PySide (Qt ...
12
votes
1answer
2k views

End of python block motion

I need a motion that moves to end/beginning of a python block, and I need another motion that moves to begining/end of previous/next method/class (all combinations). I've tried vim-indent-object, ...
5
votes
1answer
2k views

Incorrect auto-indent in python code

I have a following python code, which contains both 4 space and 2 space indents. class Foo(object): def __init__(self, flag = False): if flag: print("hello") ...
8
votes
2answers
632 views

Folding Python docstrings

According to the WIKI, scripts can be folded based on syntax. Does anyone have a solution to fold Python docstrings? Basically, all I need is to fold """ text between triple quotation marks """, like ...
17
votes
5answers
5k views

Vim syntax pattern to highlight python keyword argument

I'm struggling with learning vim regexps (I don't know any other regexp very well either), so the main problem is to define regexp that would match some_function_call(simple_value, keyword=value) ...
5
votes
1answer
5k views

How do I complete Python3 with YouCompleteMe?

I'm using YouCompleteMe to do omni complete. Most of these are fine. But when I want to complete Python3, there is something wrong. It only can complete python2. For example, import urllib # ...