23

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]\=\>...


17

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-...


17

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 ...


12

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: 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. Within ...


12

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 ...


10

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 ...


10

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 ...


9

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: ...


8

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 matching group \w\+ match word characters \) end the matching group =.*) match an = and anything until the closing ) This needs improvements but ...


7

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 ...


7

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. The unstack plugin may be of ...


6

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 ...


6

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. myobj.myfunc( "Some string parameter that goes on and on and on ...


6

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. function ReformatMultiLines() let brx = '^\s*"' let erx = '"\s*$' let fullrx = brx . '\(.\+\)' . erx ...


6

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. This will cause Vim to load its Python indent script when you edit a Python file, which will set the following option: :set indentexpr=GetPythonIndent(v:lnum) ...


5

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 datetime def seconds_to_text(seconds): """Convert number of seconds to a textual representation. >>> seconds_to_text(42) '0:00:42' >>&...


5

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 ...


5

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 let g:syntastic_python_checkers=['flake8'] ...


4

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.


4

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 dependencies... 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 ...


4

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.


4

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 ...


4

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, that it collapses the stack trace to a single error message. For example the following python script: def lumberjack(): bright_side_of_death() def ...


4

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 ...


4

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.


4

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: ~/.vim/after/ftplugin/python.vim, ...


4

A regexp that seems to work well is: \v[[:alpha:]_.]+\ze(\s?\() 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 ...


4

Flake8 already supports checking for unused imports and is integrated with Syntastic. Python developers should make sure to install flake8 into their user or virtual environment.


3

I tried to update YCM and recompile it. Now, it is fine. Python3 support was added for last month and I just updated YCM last month.


3

quickfix.py parses the traceback into a vim-friendly errorformat. Here is an example of running it on a file with a single line 1 / 0. ❯❯❯ quickfix.py tests/errors/div_by_zero.py "tests/errors/div_by_zero.py":1: ZeroDivisionError: division by zero By default, it shows user files, but it can show system files too (running it on a file containing import os; ...


Only top voted, non community-wiki answers of a minimum length are eligible