Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update if_pyth.{txt,jax} #2017

Merged
merged 1 commit into from
Apr 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 31 additions & 11 deletions doc/if_pyth.jax
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
*if_pyth.txt* For Vim バージョン 9.1. Last change: 2024 Nov 09
*if_pyth.txt* For Vim バージョン 9.1. Last change: 2025 Mar 26


VIMリファレンスマニュアル by Paul Moore
Expand Down Expand Up @@ -174,12 +174,13 @@ vim.command(str) *python-command*
:py vim.command("python print 'Hello again Python'")

vim.eval(str) *python-eval*
vim内の式評価を使って、式を評価します(|expression|を参照)。戻り値は、
vim 内の式評価を使って、式を評価します (|expression|を参照)。戻り値は、
次の通り:
- Vimの式を評価した結果が文字列か数値ならば文字列
- Vimの式を評価した結果がリストならばリスト
- Vimの式を評価した結果がVimの辞書ならば辞書
辞書とリストは再帰的に展開されます。
- Vim の式を評価した結果が文字列か数値ならば文字列
- Vim の式を評価した結果がリストならばリスト
- Vim の式を評価した結果が Vim の tuple ならば tuple
- Vim の式を評価した結果が Vim の辞書ならば辞書
辞書、リストおよび tuple は再帰的に展開されます。
例: >
:" 'textwidth' オプションの値
:py text_width = vim.eval("&tw")
Expand All @@ -190,7 +191,9 @@ vim.eval(str) *python-eval*
:" 結果は文字列であることに注意!数値に変換するには、string.atoi()
:" を使うこと。
:py str = vim.eval("12+12")

:
:py tuple = vim.eval('(1, 2, 3)')
:
:py tagList = vim.eval('taglist("eval_expr")')
< 最後のコマンドはPython辞書のPythonリストを返します。例:
[{'cmd': '/^eval_expr(arg, nextcmd)$/', 'static': 0, 'name': ~
Expand All @@ -201,10 +204,10 @@ vim.eval(str) *python-eval*
出すときに {locals} 辞書を使用します。

vim.bindeval(str) *python-bindeval*
|python-eval| と似ていますが、特殊なオブジェクトを返します
(|python-bindeval-objects| 参照)。これを使うと Vim のリスト (|List|)
や辞書 (|Dictionary|) を変更したり、Vim の関数 (|Funcref|) を呼び出し
たりできます。
|python-eval| と似ていますが、|python-bindeval-objects| で説明されてい
る特別なオブジェクトを返します。これらの Python オブジェクトを使用する
と、vim オブジェクトを変更 (|List|、|Tuple| または |Dictionary|) した
り、呼び出し (|Funcref|) たりできます。

vim.strwidth(str) *python-strwidth*
|strwidth()| と同じ。str の画面上の幅を数値で返す。タブ文字は 1 幅とし
Expand Down Expand Up @@ -676,6 +679,23 @@ vim.List オブジェクト *python-List*
print isinstance(l, vim.List) # True
class List(vim.List): # サブクラス化

vim.Tuple オブジェクト *python-Tuple*
vim |Tuple| 型へのアクセスを提供するシーケンスのようなオブジェクト。
`.locked` 属性をサポートします。|python-.locked| を参照。次のメソッドもサ
ポートします:
メソッド 説明 ~
__new__(), __new__(iterable)
`vim.Tuple()` を使用して新しい vim tuple を作成できま
す。引数がない場合、空のリストが構築されます。

例: >
t = vim.Tuple("abc") # コンストラクタ。結果: ('a', 'b', 'c')
print t[1:] # スライス
print t[0] # アイテム取得
for i in t: # イテレーション
print isinstance(t, vim.Tuple) # True
class Tuple(vim.Tuple): # サブクラス化

vim.Function オブジェクト *python-Function*
Vim の関数参照 (|Funcref|) と似た動作をする関数系オブジェクト。
特別な引数として `self` を指定できる (|Dictionary-function| 参照)。
Expand Down
27 changes: 23 additions & 4 deletions en/if_pyth.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
*if_pyth.txt* For Vim version 9.1. Last change: 2024 Nov 09
*if_pyth.txt* For Vim version 9.1. Last change: 2025 Mar 26


VIM REFERENCE MANUAL by Paul Moore
Expand Down Expand Up @@ -184,8 +184,9 @@ vim.eval(str) *python-eval*
evaluator (see |expression|). Returns the expression result as:
- a string if the Vim expression evaluates to a string or number
- a list if the Vim expression evaluates to a Vim list
- a tuple if the Vim expression evaluates to a Vim tuple
- a dictionary if the Vim expression evaluates to a Vim dictionary
Dictionaries and lists are recursively expanded.
Dictionaries, lists and tuples are recursively expanded.
Examples: >
:" value of the 'textwidth' option
:py text_width = vim.eval("&tw")
Expand All @@ -196,6 +197,8 @@ vim.eval(str) *python-eval*
:" Result is a string! Use string.atoi() to convert to a number.
:py str = vim.eval("12+12")
:
:py tuple = vim.eval('(1, 2, 3)')
:
:py tagList = vim.eval('taglist("eval_expr")')
< The latter will return a python list of python dicts, for instance:
[{'cmd': '/^eval_expr(arg, nextcmd)$/', 'static': 0, 'name': ~
Expand All @@ -207,8 +210,8 @@ vim.eval(str) *python-eval*

vim.bindeval(str) *python-bindeval*
Like |python-eval|, but returns special objects described in
|python-bindeval-objects|. These python objects let you modify (|List|
or |Dictionary|) or call (|Funcref|) vim objects.
|python-bindeval-objects|. These python objects let you modify
(|List|, |Tuple| or |Dictionary|) or call (|Funcref|) vim objects.

vim.strwidth(str) *python-strwidth*
Like |strwidth()|: returns number of display cells str occupies, tab
Expand Down Expand Up @@ -688,6 +691,22 @@ vim.List object *python-List*
print isinstance(l, vim.List) # True
class List(vim.List): # Subclassing

vim.Tuple object *python-Tuple*
Sequence-like object providing access to vim |Tuple| type.
Supports `.locked` attribute, see |python-.locked|. Also supports the
following methods:
Method Description ~
__new__(), __new__(iterable)
You can use `vim.Tuple()` to create new vim tuples.
Without arguments constructs empty list.
Examples: >
t = vim.Tuple("abc") # Constructor, result: ('a', 'b', 'c')
print t[1:] # slicing
print t[0] # getting item
for i in t: # iteration
print isinstance(t, vim.Tuple) # True
class Tuple(vim.Tuple): # Subclassing

vim.Function object *python-Function*
Function-like object, acting like vim |Funcref| object. Accepts special
keyword argument `self`, see |Dictionary-function|. You can also use
Expand Down