24
votes
Accepted
Do large numbers make vim run slowly?
I can reproduce this with the syntax/python.vim that ships with Vim 7.4.663.
Using :syntime, this seems to be caused by the following syntax group / pattern:
TOTAL COUNT MATCH SLOWEST ...
19
votes
Accepted
How do I disable syntastic for python files?
The Syntastic documentation (:help syntastic-pymode) explains what to do:
[...] To avoid both plugins opening error windows, you can either set
passive mode for python in syntastic (see ...
18
votes
Accepted
Vim Code Completion for Python 3
The ideal way is to get Vim's source and compile it yourself.
Step 1: For Debian-like systems, get the required packages:
sudo apt-get build-dep vim
Step 2: Clone Vim's source code:
cd /tmp &&...
18
votes
Accepted
End of python block motion
With the recent update (Nov 2017) of $VIMRUNTIME/ftplugin/python.vim following ft-specific motions are now available for the python language
[[ Jump backwards to begin of current/previous toplevel
[] ...
17
votes
Accepted
Vim doesn't use the correct indentation in Python files
It gets reset by the Python filetype plugin; from /usr/share/vim/vim74/ftplugin/python.vim:
" As suggested by PEP8.
setlocal expandtab shiftwidth=4 softtabstop=4 tabstop=8
This file is loaded ...
17
votes
Accepted
How can I fix "missing" syntax highlighting for Python keywords such as "self"?
How syntax highlighting works in brief:
In syntax/<filetype>.vim the syntax rules are defined with the :syntax command. This command defines, well, syntax. It says "if text matches this regular ...
14
votes
Accepted
Vim syntax pattern to highlight python keyword argument
With these settings:
syn region FCall start='[[:alpha:]_]\i*\s*(' end=')' contains=FCall,FCallKeyword
syn match FCallKeyword /\i*\ze\s*=[^=]/ contained
hi FCallKeyword ctermfg=yellow
I get:
Here:
...
12
votes
Accepted
How to format files on save using black with neovim and coc
This is a coc.nvim setup procedure that works for Neovim, which aims to:
Provide static type checking from a Python virtualenv (e.g. I have created a venv called coc with pyenv, which resides in ~/....
11
votes
Quickfix support for Python tracebacks
Built in compiler plugin pyunit
As already suggested by jamessan, one option is to use the built in compiler plugin pyunit:
:compiler pyunit
:set makeprg=python3\ %
:make
This has the downside, ...
10
votes
Accepted
Argument completion for python
By default, (with a minimal vimrc, and no plugins installed), this is already possible.
Vim ships with multiple filetype plugins and some of these plugins offer omni-completion right out of the box. ...
10
votes
Accepted
Why is "set noexpandtab" in my ~/.vimrc ignored when I open a file?
It is not ignored, it is overwritten by your filetype plugin. In this case the python plugin. You can verify that like Marth said, with the :verbose command:
:verbose set expandtab?
If you want to ...
10
votes
Python debugging
There are alternatives.
Plain ol' pdb can be integrated into vim with
vimpdb
vebugger, etc
(My own favourite) pudb can be integrated with
pudb.vim
vim-pudb
And the popular ipdb can be integrated ...
10
votes
Accepted
8
votes
Accepted
Incorrect auto-indent in python code
In this case, the auto-indentation seems confused because the def __init__() is indented by four spaces, while the others are indented by two spaces. This is valid Python, but the Vim Python ...
8
votes
Accepted
Quickfix support for Python tracebacks
Vim comes with a set of "compiler" scripts, one of which is called "pyunit". If you run :compiler pyunit and then :make (with your suggested value for 'makeprg'), quickfix is ...
8
votes
Vim syntax pattern to highlight python keyword argument
Here is where you can start from:
/([^,]\+,\s\(\w\+\)=.*)
Decomposing:
/( start matching a (
[^,]\+ match multiple characters that are not ,
,\s match a , and a space
\( start a ...
8
votes
Accepted
Automatic whitespace in python
You want to have this setting:
" ---- Minimal configuration:
set smartindent " Do smart autoindenting when starting a new line
set shiftwidth=4 " Set number of spaces per auto indentation
set ...
7
votes
Accepted
Plugin for vim that auto indents after a : when editing python?
Try adding the following lines to your .vimrc:
syntax on
filetype plugin indent on
N.B. The plugin is not necessary for indenting, but it enables filetype plugins to run, which you probably want.
...
6
votes
Vim syntax pattern to highlight python keyword argument
In addition to @Nobe4 answer you could do the following:
Create the file ~/.vim/after/syntax/python.vim
Put theses line in the file:
syntax match PythonArg /(.*\,\s*\zs\w\+\ze\s*=.*)/
hi PythonArg ...
6
votes
How can I reformat a multi-line string in vim when using the Python filetype?
If this is a regular occurrence, you'd be best off looking for a plugin or using @Sukima 's function. If I were doing this on the fly however, here's what I'd probably do:
Add a newline after the ...
6
votes
How can I reformat a multi-line string in vim when using the Python filetype?
Oh that's a tough one. I think the best approach is possibly a macro but more likely a plugin. Here is an example I whipped up (I need a better hobby). It seemed to work for me but would need the ...
6
votes
Accepted
Strange Fold Info Showing in Gutter
What you see is the 'foldcolumn' setting for opened folds. If you don't want it, simply disable it: :set foldcolumn=0 To find out where it was set, enter :verbose set foldcolumn? You might also play ...
5
votes
Vim Code Completion for Python 3
jedi-vim works fine for me now with +python3 support in vim. In added the following option to my .vimrc:
let g:jedi#force_py_version = 3.
5
votes
How to set the relative indent after breaking Python lines?
The script that controls Vim's indentation of Python files is located at $VIMRUNTIME/indent/python.vim. You can see the help file for it with :help ft-python-indent. From that, we learn there are a ...
5
votes
Test python function from within editor
Not really a "Vim answer", but writing a unit test and running the unit test(s) for the current file is probably the best way to do this.
Specifically for Python you can use doctests:
import ...
5
votes
Accepted
Closing error window
It's aquickfix window, and you can close it with the command :cclose.
The above is rubbish, and I apologise for answering too hastily.
All the yapf plugins I found seem to work by replacing your ...
5
votes
Accepted
Is there a % equivalent for editing python code?
That functionality is provided by the matchit plugin that is bundled with Vim. The distributed C filetype plugin includes the configuration b:match_words that defines those jumps for the matchit ...
5
votes
How can I configure Black the python code formatter to indent 2 spaces instead of 4?
The whole point of Black is that it is not configurable. It calls itself "the uncompromising code formatter".
Its name comes from the Henry Ford quote about the Model T:
"any color you ...
4
votes
Accepted
How to check the syntax of a file on the fly?
If you're using Vim 8 or Neovim, you can use Asynchronous Lint Engine.
Note that it doesn't work well with Syntastic (source):
ALE conflicts with Syntastic. Uninstall it, or disable this warning ...
4
votes
Vim Code Completion for Python 3
Writing this more as a note to myself than anything, but maybe this will be useful to some: on Arch Linux, you can install a version of vim compiled with python3:
# pacman -S vim-python3
resolving ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
filetype-python × 81syntax-highlighting × 14
vimrc × 10
indentation × 9
neovim × 7
autocompletion × 6
regular-expression × 4
formatting × 4
plugin-coc × 4
filetype × 3
plugin-you-complete-me × 3
ide × 3
python × 3
plugin-python-mode × 3
key-bindings × 2
folding × 2
plugin-system × 2
whitespace × 2
makeprg × 2
plugin-syntastic × 2
vim8 × 2
debugging × 2
plugin-jedi-vim × 2
gvim × 1
autocmd × 1