1
1
*if_pyth.txt* Nvim
2
2
3
3
4
-
VIM REFERENCE MANUAL by Paul Moore
4
+
NVIM REFERENCE MANUAL
5
5
6
6
7
-
The Python Interface to Vim *if_pyth* *python* *Python*
7
+
The Python Interface to NVim *if_pyth* *python* *Python*
8
8
9
9
See |provider-python| for more information.
10
10
@@ -134,7 +134,7 @@ Instead, put the Python command in a function and call that function:
134
134
Note that "EOF" must be at the start of the line.
135
135
136
136
==============================================================================
137
-
The vim module *python-vim* *python2*
137
+
The vim module *python-vim*
138
138
139
139
Python code gets all of its access to vim (with one exception - see
140
140
|python-output| below) via the "vim" module. The vim module implements two
@@ -322,14 +322,13 @@ Output from Python *python-output*
322
322
supported, and may cause the program to crash. This should probably be
323
323
fixed.
324
324
325
-
*python2-directory* *python3-directory* *pythonx-directory*
325
+
*python3-directory* *pythonx-directory*
326
326
Python 'runtimepath' handling *python-special-path*
327
327
328
328
In python vim.VIM_SPECIAL_PATH special directory is used as a replacement for
329
329
the list of paths found in 'runtimepath': with this directory in sys.path and
330
330
vim.path_hooks in sys.path_hooks python will try to load module from
331
-
{rtp}/python2 (or python3) and {rtp}/pythonx (for both python versions) for
332
-
each {rtp} found in 'runtimepath'.
331
+
{rtp}/python3 and {rtp}/pythonx for each {rtp} found in 'runtimepath'.
333
332
334
333
Implementation is similar to the following, but written in C: >
335
334
@@ -401,8 +400,8 @@ vim._get_paths *python-_get_paths*
401
400
hook. You should not rely on this method being present in future
402
401
versions, but can use it for debugging.
403
402
404
-
It returns a list of {rtp}/python2 (or {rtp}/python3) and
405
-
{rtp}/pythonx directories for each {rtp} in 'runtimepath'.
403
+
It returns a list of {rtp}/python3 and {rtp}/pythonx
404
+
directories for each {rtp} in 'runtimepath'.
406
405
407
406
==============================================================================
408
407
Buffer objects *python-buffer*
@@ -590,6 +589,11 @@ functions to evaluate Python expressions and pass their values to Vim script.
590
589
==============================================================================
591
590
Python 3 *python3*
592
591
592
+
As Python 3 is the only supported version in Nvim, "python" is synonymous
593
+
with "python3" in the current version. However, code that aims to support older
594
+
versions of Neovim, as well as Vim, should prefer to use "python3"
595
+
variants explicitly if Python 3 is required.
596
+
593
597
*:py3* *:python3*
594
598
:[range]py3 {stmt}
595
599
:[range]py3 << [endmarker]
@@ -619,66 +623,43 @@ Raising SystemExit exception in python isn't endorsed way to quit vim, use: >
619
623
:py vim.command("qall!")
620
624
<
621
625
*has-python*
622
-
You can test what Python version is available with: >
623
-
if has('python')
624
-
echo 'there is Python 2.x'
626
+
You can test if Python is available with: >
627
+
if has('pythonx')
628
+
echo 'there is Python'
625
629
endif
626
630
if has('python3')
627
631
echo 'there is Python 3.x'
628
632
endif
629
633
634
+
Python 2 is no longer supported. Thus `has('python')` always returns
635
+
zero for backwards compatibility reasons.
636
+
630
637
==============================================================================
631
638
Python X *python_x* *pythonx*
632
639
633
-
Because most python code can be written so that it works with Python 2.6+ and
634
-
Python 3, the pyx* functions and commands have been written. They work the
635
-
same as the Python 2 and 3 variants, but select the Python version using the
636
-
'pyxversion' setting.
637
-
638
-
Set 'pyxversion' in your |vimrc| to prefer Python 2 or Python 3 for Python
639
-
commands. Changing this setting at runtime risks losing the state of plugins
640
-
(such as initialization).
641
-
642
-
If you want to use a module, you can put it in the {rtp}/pythonx directory.
643
-
See |pythonx-directory|.
640
+
The "pythonx" and "pyx" prefixes were introduced for python code which
641
+
works with Python 2.6+ and Python 3. As Nvim only supports Python 3,
642
+
all these commands are now synonymous to their "python3" equivalents.
644
643
645
644
*:pyx* *:pythonx*
646
-
`:pyx` and `:pythonx` work similar to `:python`. To check if `:pyx` works: >
645
+
`:pyx` and `:pythonx` work the same as `:python3`. To check if `:pyx` works: >
647
646
:pyx print("Hello")
648
647
649
648
To see what version of Python is being used: >
650
649
:pyx import sys
651
650
:pyx print(sys.version)
652
651
<
653
652
*:pyxfile* *python_x-special-comments*
654
-
`:pyxfile` works similar to `:pyfile`. But you can add a "shebang" comment to
655
-
force Vim to use `:pyfile` or `:py3file`: >
656
-
#!/any string/python2 " Shebang. Must be the first line of the file.
657
-
#!/any string/python3 " Shebang. Must be the first line of the file.
658
-
# requires python 2.x " Maximum lines depend on 'modelines'.
659
-
# requires python 3.x " Maximum lines depend on 'modelines'.
660
-
Unlike normal modelines, the bottom of the file is not checked.
661
-
If none of them are found, the 'pyxversion' option is used.
662
-
*W20* *W21*
663
-
If Vim does not support the selected Python version a silent message will be
664
-
printed. Use `:messages` to read them.
653
+
`:pyxfile` works the same as `:py3file`.
665
654
666
655
*:pyxdo*
667
-
`:pyxdo` works similar to `:pydo`.
656
+
`:pyxdo` works the same as `:py3do`.
668
657
669
658
*has-pythonx*
670
-
To check if pyx* functions and commands are available: >
659
+
To check if `pyx*` functions and commands are available: >
671
660
if has('pythonx')
672
661
echo 'pyx* commands are available. (Python ' . &pyx . ')'
673
662
endif
674
663
675
-
If you prefer Python 2 and want to fallback to Python 3, set 'pyxversion'
676
-
explicitly in your |.vimrc|. Example: >
677
-
if has('python')
678
-
set pyx=2
679
-
elseif has('python3')
680
-
set pyx=3
681
-
endif
682
-
683
664
==============================================================================
684
665
vim:tw=78:ts=8:noet:ft=help:norl:
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4