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
0answers
13 views

How to select a python interpreter in vim

I have multiple versions of python on my ubuntu system, python2.7 which is default one and i have installed python3.8. I have a python module installed in python3.8 which is not installed in python2.7....
0
votes
0answers
27 views

How dose colorscheme file working when python.vim file not exist?

I deleted python.vim in ~./Vim/vim82/syntax directory, and define colorscheme.vim in ~./Vim/vim82/colors directory. The colorscheme.vim contain this code call <sid>hi('pythonNumber', s:...
1
vote
1answer
38 views

Convert print statements to log statements using a custom mapping

I want to write or find a plugin that helps me convert print statements to log statements in Python 3. Consider a situation: I am writing some code, I want to add a feature based around some API, I ...
1
vote
1answer
51 views

Why is my setting of `set softtabstop` in vimrc being clobbered when editing python files?

I am using vim 8.0.1763 on CentOS 8.1. Here is my ~/.vimrc " Cool vim plugins : http://vimawesome.com/plugin/fugitive-vim set number filetype plugin on " https://stackoverflow.com/questions/...
1
vote
0answers
19 views

Signature pop-up describes dataclass as “The most base type”

I'm using coc-python for Python IDE-like features. If I define a dataclass I would expect the signature pop-up to show me which fields an instance of this class expects. Instead I get: MyClass() ------...
3
votes
2answers
54 views

Debug how vim calls makeprg

I'm trying to set up pylint to work with :make command in Vim 8.2. I've set :compiler pylint but running :make gives me pylint's help message, so some arguments seem to be passed incorrectly. :set ...
0
votes
1answer
35 views

What's the fastest way to go about defining functions in Python?

def counter(num): I always get stuck inside of the parenthesis and find myself pressing ESC, going back to Normal mode, then pressing A to append the colon to the end of the line. Is there a faster ...
2
votes
1answer
111 views

Jump to definition in Python using static code analysis

I wonder if there is a way to jump to Python method definition in VIM using static code analysis (as described in https://gist.github.com/igemnace/dfa545d0d71228e010876d48a420a50b). For example, if I ...
3
votes
3answers
887 views

How do I display a Python docstring in Vim

I've recently decided to give Vim a try and am trying to get it set up for work with Python. I've installed YCM, so I have autocompletion now, which is good, but there are a few things documentation-...
1
vote
0answers
1k views

View pylint errors using coc and neovim

For the following code there is an error in the gutter, but I don't know how to view the actual message for it. Similarly here: In the bottom right of the editor are warnings and errors: But I don'...
3
votes
1answer
3k views

How to format files on save using black with neovim and coc

I'm trying to have python files format on save using black and neovim, with coc. Coc config I have the following coc config: { "coc.preferences.useQuickfixForLocations": true, "coc....
0
votes
1answer
123 views

Python script not running through vim but runs on Windows CMD

I have recently switched to vim from VS Code. I have Vim 8.2. I have put these lines in my _vimrc file so that I can run python in vim by pressing F9:- autocmd FileType python map <buffer> <...
1
vote
1answer
56 views

Start vim-coverage when opening a python file

If I run the command CoverageShow coverage.py when I have a python file open and a .coverage report in my directory it does a nice job of showing me which lines are included in my testing. I would ...
2
votes
2answers
53 views

How to exclude a pattern between a pair of parentheses?

I have the following Python code z=xyz%10 gvu.set_ticks(ax, xticks=[45, 50], yticks=[-25, -20, -15]) After this substitution, in visual mode :s/\([^=]\)\ *\(=\)\ *\([^=]\)/\1 \2 \3/g ...
3
votes
1answer
104 views

Vim thinks Python @ operator is decorator

Python3 has the matrix multiplication operator (@) which is used to multiply numpy matrices. But when we write something like A = B @ C in vim, the @ C portion gets highlighted. Apparently Python has ...
1
vote
1answer
367 views

Autocmd with a python file not working

I'm using the regular Vim that comes with Ubuntu. I have the following line of code in my .vimrc: autocmd filetype py nnoremap <F10> :w <bar> !python3 %<CR> It's not working, ...
1
vote
1answer
98 views

How to easily switch flake8 between python 2 and 3

I'm working with python 2.7 scripts that I need to update to python 3.8 while maintaining backwards compatibility. vim-flake8 on my mac has been working great up until now for python 2.7, but I can't ...
3
votes
2answers
3k views

How can I configure Black the python code formatter to indent 2 spaces instead of 4?

I'm using the psf/black plugin, I install and load it with vimplug: Plug 'psf/black' and I use it with <leader>f: autocmd FileType python nmap <leader>f :Black<CR> I use and prefer ...
3
votes
3answers
144 views

Pretty python comments

I comment sections in python via a centered title surrounded by #. What I would like is to make a command so that I can automatically generate such headers. For example, to generate a line like the ...
1
vote
1answer
846 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
441 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-...
1
vote
1answer
2k 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 ...
3
votes
0answers
543 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
315 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
38 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
267 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
782 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
75 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 ...
3
votes
1answer
763 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
230 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) ...
10
votes
3answers
17k 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
132 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
3k 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
150 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 ...
4
votes
1answer
931 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
721 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
538 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
513 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
174 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
735 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
3k 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(...
5
votes
3answers
4k 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, ...
11
votes
1answer
6k 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 $ vim ...
1
vote
1answer
352 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 ...
5
votes
1answer
235 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 ...
2
votes
1answer
773 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 ...
1
vote
1answer
10k 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 ?
3
votes
1answer
596 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
880 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 ...