Skip to content
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
96 changes: 68 additions & 28 deletions doc/cmdline.jax
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
*cmdline.txt* For Vim バージョン 9.1. Last change: 2025 Sep 10
*cmdline.txt* For Vim バージョン 9.1. Last change: 2025 Sep 15


VIMリファレンスマニュアル by Bram Moolenaar
Expand Down Expand Up @@ -713,15 +713,16 @@ Exコマンドには、その前に行単位の範囲を指定できるものが

基本事項はユーザーマニュアルの |10.3| 章で説明されている。

|Vim9| script では継続行の曖昧さを避けるため、範囲にはコロンが接頭辞として必要
となる。例として、"+" は範囲として使えるが式の継続でもある: >
|Vim9| script では、継続行の曖昧さを避けるため、範囲にはコロンが接頭辞として必
要となる。例として、"+" は範囲として使えるが式の継続でもある: >
var result = start
+ print
"+" が範囲の場合はコロンが接頭辞として必要になる: >
var result = start
<ここにあるように "+" が範囲を表す場合、Vim9 script ではコロンを前に付ける必要
がある (そうしないとエラー |E1050| が発生する): >
vim9script
:+ print
<
*:,* *:;*
*:,* *:;*
区切りに ';' を使うと、次の行指定子を解釈する前にカーソル位置がその行に移動
する。',' ではこうならない。例: >
4,/この行/
Expand All @@ -730,32 +731,71 @@ Exコマンドには、その前に行単位の範囲を指定できるものが
< 5行目から、5行目より後の、"あの行" がマッチする行まで。

ほとんどのコマンドでは、範囲の既定値はカーソルのある行である。しかしコマンド
":write", ":global" での既定値はファイル全体 (1,$) である。

コマンドに必要以上の行指定子が指定されたときは、先頭の方に指定されたものから順
に除外される。

":write", ":global" での既定値はバッファ全体 (1,$) である。

コマンドに必要な数よりも多くの行指定子が指定された場合、コンマで区切られている
ときは、左端の行指定子は無視される。例えば、次の例の -2,+ は次のようになる: >
:-2,+,-2,. print
<セミコロンで区切られている場合、左端の指定子から最後から2番目の指定子までが合
計される。例えば、次の場合、-4 + 3 - 1 = -2 となる: >
:-4;+3;-1;+2 print
<
行番号は以下の方法で指定できる: *:range* *{address}*
{number} 絶対的な行番号 *E1247*
. 現在の行 *:.*
$ ファイルの最終行 *:$*
% 1,$と同じ (ファイル全体) *:%*
't マーク tの位置 (小文字) *:'*
'T マーク Tの位置 (大文字); マーク位置が別ファイルにある
ときには範囲指定には使えない
/{pattern}[/] 次に {pattern} のマッチする行 (下向き) *:/*
以下の |:range-pattern| も参照
?{pattern}[?] 次に {pattern} のマッチする行 (上向き) *:?*
以下の |:range-pattern| も参照
\/ 次に直前の検索パターンのマッチする行 (下向き)
\? 次に直前の検索パターンのマッチする行 (上向き)
\& 次に直前の置換元パターンのマッチする行 (下向き)
. 現在行 *:.*
$ バッファの最終行 *:$*
% 1,$ と同じ (バッファ全体) *:%*
* '<,'> と同じ (最後に選択されたビジュアル領域の行。下
の |:star| を参照)
'x マーク x の位置の行 *:'x*
(ここで x は {a-z} の任意のマーク)
'X マーク X の位置の桁 *:'X*
(ここで X は {A-Z0-9} の任意のマークであるが、X が別の
バッファにある場合は範囲指定で使用できない)
'[ 最新の変更またはヤンクの最初の行 *:'[*
'] 最新の変更またはヤンクの最後の行 *:']*
'< 最後に選択されたビジュアル領域の最初の行 *:'<*
'> 最後に選択されたビジュアル領域の最後の行 *:'>*
'' 最後のジャンプの前の位置の行、または最後 *:''*
に "m'"/"m`" コ>マンドが与えられた行 (た
だし、カレントバッファにない場合は '' は
1 になる)
'" 最後にバッファを出た時のカーソル位置の行 *:'quote*
'^ 最後に挿入モードを停止したときのカーソル *:'^*
位置の行
'. バッファが最後に変更されたときのカーソル *:'.*
位置の行
'( 現在の文の最初の文字の行 *:'(*
') 現在の文の末尾の後の最初の文字の行 *:')*
'{ カーソルのある段落の前の最初の空行 *:'{*
'} カーソルのある段落の後の最初の空行 *:'}*
/{pattern}[/] {pattern} がマッチする次の行 *:/*
下記の |:range-pattern| も参照
?{pattern}[?] {pattern} がマッチする前の行 *:?*
下記の |:range-pattern| も参照
\/ 最新の検索パターンにマッチする次の行
\? 最新の検索パターンにマッチする前の行
\& 最新の置換パターンがマッチする次の行

Note: 「次の行」と「前の行」には、現在の行に現れるマッチは含まれない。

*:range-offset*
これらの後に '+' または '-' と数値を付けてもよい (複数も可)。この数は直前の行
番号に加算または減算される。数が省略された場合は 1 が指定されたと見なされる。
もし '+' や '-' の前に何も無い場合は現在行が使われる。
*:range-closed-fold*
各行指定子の後には、1つ以上の '+' または '-' と、オプションの数値を続けること
ができる。その値は、前の行番号に加算または減算される。
例えば、'x+2 はマーク x を含む行の 2 行後を表す。数値を省略した場合、'+' には
+1、'-' には -1 がそれぞれ適用される。つまり、'x++ と 'x+2 は同義である。'+'
または '-' の前に何も指定しない場合、[range] の最初の行番号として、現在行が相
対的な開始点として使用される。つまり、-,. は「現在行の 1 つ前の行から現在行ま
で」を意味する。[range] の 2 番目の行番号の値は、行番号をコンマで区切るかセミ
コロンで区切るかによって異なる (|:,| および |:;| を参照)。
例: カーソルが現在行の下の行にある場合、以下のコマンドはいずれもタグ行
":range-offset" と行 "Each..." を出力する: >
:-11;+1 print
:-----------,-10 print
:?Each line?-;+ print
:'{+,'{+2 print
:'{+1;')-1 print
< *:range-closed-fold*
コンマの後の行番号が閉じた折り畳みにある場合、折り畳みの最後の行に調整されるた
め、折り畳み全体が含まれる。

Expand Down
109 changes: 80 additions & 29 deletions en/cmdline.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
*cmdline.txt* For Vim version 9.1. Last change: 2025 Sep 10
*cmdline.txt* For Vim version 9.1. Last change: 2025 Sep 15


VIM REFERENCE MANUAL by Bram Moolenaar
Expand Down Expand Up @@ -745,16 +745,17 @@ Some Ex commands accept a line range in front of them. This is noted as

The basics are explained in section |10.3| of the user manual.

In |Vim9| script a range needs to be prefixed with a colon to avoid ambiguity
In |Vim9| script, a range needs to be prefixed with a colon to avoid ambiguity
with continuation lines. For example, "+" can be used for a range but is also
a continuation of an expression: >
var result = start
+ print
If the "+" is a range then it must be prefixed with a colon: >
var result = start
<If the "+" is a range, as it is here, in Vim9 script it must be prefixed
with a colon (otherwise you will get error |E1050|): >
vim9script
:+ print
<
*:,* *:;*
*:,* *:;*
When separated with ';' the cursor position will be set to that line
before interpreting the next line specifier. This doesn't happen for ','.
Examples: >
Expand All @@ -764,36 +765,86 @@ Examples: >
< from line 5 till match with "that line" after line 5.

The default line specifier for most commands is the cursor position, but the
commands ":write" and ":global" have the whole file (1,$) as default.

If more line specifiers are given than required for the command, the first
one(s) will be ignored.

commands ":write" and ":global" have the whole buffer (1,$) as default.

If more line specifiers are given than required for the command, when comma
separated, the leftmost one(s) will be ignored, e.g., the -2,+ in this: >
:-2,+,-2,. print
<When semicolon separated, the leftmost specifier to the penultimate one are
summed, e.g., -4 + 3 - 1 = -2, in this: >
:-4;+3;-1;+2 print
<
Line numbers may be specified with: *:range* *{address}*
{number} an absolute line number *E1247*
. the current line *:.*
$ the last line in the file *:$*
% equal to 1,$ (the entire file) *:%*
't position of mark t (lowercase) *:'*
'T position of mark T (uppercase); when the mark is in
another file it cannot be used in a range
/{pattern}[/] the next line where {pattern} matches *:/*
. the current line *:.*
$ the last line of the buffer *:$*
% equal to 1,$ (the entire buffer) *:%*
* equal to '<,'> (the lines of the last
selected Visual area; see |:star| below)
'x the line of the position of mark x *:'x*
(where x is any {a-z} mark)
'X the line of the position of mark X *:'X*
(where X is any {A-Z0-9} mark, though
when X is in another buffer it cannot
be used in a range)
'[ the first line of the most recent *:'[*
change or yank
'] the last line of the most recent *:']*
change or yank
'< the first line of the most recently *:'<*
selected Visual area
'> the last line of the most recently *:'>*
selected Visual area
'' the line of the position before the *:''*
latest jump, or where the last "m'"/"m`"
command was given (though '' is 1 if it
isn't in the current buffer)
'" the line of the cursor position when *:'quote*
last exiting the buffer
'^ the line of the cursor position the *:'^*
last time Insert mode was stopped
'. the line of the cursor position when the *:'.*
buffer was last changed
'( the line of the first character of the *:'(*
current sentence
') the line of the first character after *:')*
the end of the current sentence
'{ the first empty line before the *:'{*
paragraph containing the cursor
'} the first empty line after the *:'}*
paragraph containing the cursor
/{pattern}[/] the next line where {pattern} matches *:/*
also see |:range-pattern| below
?{pattern}[?] the previous line where {pattern} matches *:?*
?{pattern}[?] the previous line where {pattern} matches *:?*
also see |:range-pattern| below
\/ the next line where the previously used search
pattern matches
\? the previous line where the previously used search
pattern matches
\& the next line where the previously used substitute
pattern matches
\/ the next line where the most recent
search pattern matches
\? the previous line where the most recent
search pattern matches
\& the next line where the most recent
substitute pattern matches

Note: "next line" and "previous line" do not include matches appearing
in the current line.

*:range-offset*
Each may be followed (several times) by '+' or '-' and an optional number.
This number is added or subtracted from the preceding line number. If the
number is omitted, 1 is used. If there is nothing before the '+' or '-' then
the current line is used.
*:range-closed-fold*
Each line specifier may be followed by one or more '+' or '-' and an optional
number. That value is added or subtracted from the preceding line number.
So, for example, 'x+2 is two lines after the line containing mark x. If the
number is omitted, +1 is used for each '+' and -1 for each '-' so, e.g., 'x++
and 'x+2 are synonymous. If there is nothing before the '+' or '-', for the
first line number in [range] the current line is used as the relative
starting point. So, -,. means, "the line before the current line to the
current line". The value of the second line number in [range] depends on
whether a comma or semicolon separates the line numbers (see |:,| and |:;|).
Examples: If the cursor is within the line below this one, any of these
commands will print the tag line ":range-offset" and the line, "Each...": >
:-11;+1 print
:-----------,-10 print
:?Each line?-;+ print
:'{+,'{+2 print
:'{+1;')-1 print
< *:range-closed-fold*
When a line number after the comma is in a closed fold it is adjusted to the
last line of the fold, thus the whole fold is included.

Expand Down