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
4
votes
1answer
638 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
902 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
726 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
878 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
1k 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 ...
6
votes
1answer
1k 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
605 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 ...
13
votes
1answer
10k 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 ...
4
votes
2answers
1k 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(...
8
votes
2answers
7k 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
780 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
1k 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
571 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 ...
20
votes
1answer
4k 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
4k 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
1k 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 ...
19
votes
5answers
7k 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) ...
4
votes
1answer
6k 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 # ...
1
vote
0answers
365 views

Ultisnips not working on first load of python file

I've installed the Ultisnips plugin with Pathogen. All in all it seems to be working fine. My problem is that it doesn't seem to work for the first python file I load, but it works for all the rest. ...
2
votes
0answers
92 views

Automatically determine whether to use spaces or tabs [duplicate]

I like to use tabs for indentation (hey, don't bully me!). But 33% of other programmers prefer spaces. The norm with Python is to use spaces for indetation. Even so, I configured Vim to use tabs with ...
20
votes
4answers
5k views

Quickfix support for Python tracebacks

Say I have a python script with a runtime error: $ cat example.py #! /usr/bin/env python3 a = 1/0 which gives: $ python3 example.py Traceback (most recent call last): File "example.py", line ...
3
votes
0answers
592 views

Highlight python raw strings as regular expression

I heard someone had set up their editor to highlight python raw strings as regular expressions, e.g. for Django: urls(r'^site1/(\d)*/new$'', ...) Unfortunately my googleing doesn't get me anything. ...
9
votes
1answer
4k views

Argument completion for python

Is there a way to get argument completion for python? I am currently using a combination of ctags, python-mode and YouCompleteMe, but I am missing a function to autocomplete the arguments of a ...
18
votes
1answer
7k views

How do I disable syntastic for python files?

I have the syntastic and python-mode plugins installed and they both include syntax checkers. I think the python-mode syntax checker is more versitle for python files so I would like to just use that ...
18
votes
1answer
1k views

Do large numbers make vim run slowly?

This seems like a really daft question, but I have a Python file that has a number in it that's a thousand digits long and that file seems to be running very slowly, I'm not sure if there's some kind ...
29
votes
6answers
19k views

Vim Code Completion for Python 3

I am running Debian Jessie and use the current vim-nox (with +python -python3). I am having a hard time trying to program in Python 3, as I struggle with Python 3 code completion. YouCompleteMe doesn'...
27
votes
4answers
3k views

How can I reformat a multi-line string in vim when using the Python filetype?

Let's assume I am editing some Python code in vim that looks a bit like: myobj.myfunc("Some string parameter that goes on and on and on and on and sometimes doesn't" "split very" ...
6
votes
1answer
414 views

equalprg to use for Python

Python is whitespace dependent, and it can't be totally autoindented for that reason, but there are a lot of extra stuff that should be possible to do automatically to comply with PEP8. Things like ...

1
2