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 AVERAGE NAME PATTERN
73.870736 20 0 3.940215 3.693537 pythonNumber \%(^\|\W\)\@<=\d*\.\d\+\%([eE][+-]\=\d\+\)\=[jJ]\=\>...
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 && git clone https://github.com/vim/vim.git && cd vim
Step 3: Configure, Make, Install
./configure --with-features=huge --enable-multibyte --enable-...
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 syntastic_mode_map), or
disable lint checks in "python-mode", [...]
So you should be able to disable automatic syntax checking for Python files with something like ...
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
 Jump backwards to end of previous toplevel
][ Jump forwards to end of current toplevel
]] Jump forwards to begin of next toplevel
[m Jump backwards to begin of ...
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 expression, it's a string", and so forth. To do so, it assigns a highlight group. It does not say anything about colours as such.
:highlight says "highlight ...
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 define a syntax region within which keyword arguments can be found, which would be the function call. The contains option lets me nest function calls.
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 every time a Python file is loaded. Personally I find adding indentation settings here a bit surprising though.
At any rate, to override this use this in your vimrc:
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. For example, python comes with pythoncomplete.vim.
If you use the default pythoncomplete.vim that ships with Vim, (i.e. no YouCompleteMe, no python-mode, no ...
Here is where you can start from:
/( start matching a (
[^,]\+ match multiple characters that are not ,
,\s match a , and a space
\( start a matching group
\w\+ match word characters
\) end the matching group
=.*) match an = and anything until the closing )
This needs improvements but ...
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 expandtab " When using <Tab>, put spaces instead of a <tab> character
" ---- Good to have for consistency
" set tabstop=4 " Number of spaces that ...
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 indentation code doesn't seem to be advanced enough to deal with this.
In the Python source there's Tools/scripts/reindent.py, which can fix indentation. When I run it ...
Built in compiler plugin pyunit
As already suggested by jamessan, one option is to use the built in compiler plugin pyunit:
:set makeprg=python3\ %
This has the downside, that it collapses the stack trace to a single error message. For example the following python script:
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 populated as you expect. However, it only works well if there's one level to the stack trace.
Improving that compiler script would be a useful exercise.
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 guibg=blue
Adapt the second one with your prefered values.
This will create a syntax file which will add a syntax match for your arguments followed by a = and ...
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 opening paren and before the closing paren so that strings are on separate lines.
"Some string parameter that goes on and on and on ...
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 python indenting plugin to indent properly. Try it out.
let brx = '^\s*"'
let erx = '"\s*$'
let fullrx = brx . '\(.\+\)' . erx
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 with increasing the foldcolumn value, so that the display looks a little bit better.
Try adding the following lines to your .vimrc:
filetype plugin indent on
N.B. The plugin is not necessary for indenting, but it enables filetype plugins to run, which you probably want.
This will cause Vim to load its Python indent script when you edit a Python file, which will set the following option:
There are alternatives.
Plain ol' pdb can be integrated into vim with
(My own favourite) pudb can be integrated with
And the popular ipdb can be integrated with
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:
"""Convert number of seconds to a textual representation.
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 entire file contents with the result of running the yapf command. (This is expected functionality, as yapf is a code formatter.)
You should be able to go back ...
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 plugin.
Unfortunately, the distributed python filetype does not include a similar change. You can however configure b:match_words for that case. Simply put the ...
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 overwrite the setting in the filetype plugin, you should go for one of the following ways:
Put your settings in a after file:
Using Ubuntu, I couldn't figure out what was calling python or to change the default environment for all instances of syntastic. That would have been desirable.
Instead what I did was install flake8,
pip3 install flake8
Then you can easily configure this to work by adding the following line to your ~/.vimrc
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 with let g:ale_emit_conflict_warnings = 0 in your vimrc file, before plugins are loaded.
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
looking for conflicting packages...
:: vim-python3 and vim are in conflict. Remove vim? [y/N] y
Type y and this will replace your existing vim ...
Since a couple of weeks, YouCompleteMe does support Python3 completion using Jedi via a JediHTTP wrapper. Only install YouCompleteMe (no need to install jedi-vim) according to the installation instructions and add the following line to your .vimrc:
let g:ycm_python_binary_path = '/usr/bin/python3'
This forces YCM to use Jedi with Python3 (default is to use ...
A regexp that seems to work well is:
Or for syntax highlighting (see How can I add additional syntax highlighting rules in my local vimrc? on how to add this to your vimrc):
:syntax match pythonFunction /\v[[:alpha:]_.]+\ze(\s?\()/
:hi def link pythonFunction Function
To break it down:
\v – "very magic" mode so we don't have ...