Skip to content

Commit 89561b1

Browse files
authored
Merge pull request #281 from mnishz/change_for_Vim_8.1
Update change from Vim 8.0 to 8.1
2 parents 7cd4cf4 + 187df96 commit 89561b1

File tree

2 files changed

+117
-7
lines changed

2 files changed

+117
-7
lines changed

doc/change.jax

Lines changed: 59 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
*change.txt* For Vim バージョン 8.0. Last change: 2017 Feb 17
1+
*change.txt* For Vim バージョン 8.1. Last change: 2018 May 12
22

33

44
VIMリファレンスマニュアル by Bram Moolenaar
@@ -515,9 +515,10 @@ Note: 'nrformats' が "bin" を含んでいるとき、'0x' または '0X' で
515515

516516
'shiftround' がオンのとき、インデントは 'shiftwidth' の倍数に丸められる。
517517

518-
'shiftwidth' がオンのとき、あるいは 'cindent' がオンで 'cinkeys' が値 0 の '#'
519-
を含むとき、右方向へのシフトは '#' で始まる行に適用されない (これらの行は、行
520-
の最初に位置すべきCプリプロセッサー指令であると考えられる)。
518+
'smartindent' がオンのとき、あるいは 'cindent' がオンで 'cinkeys' が値 0 の
519+
'#' を含むとき、右方向へのシフトは '#' で始まる行に適用されない (これらの行は、
520+
行の最初に位置すべきCプリプロセッサー指令であると考えられる)。これは 'cino'
521+
プションで変更することができる、|cino-#| を参照。
521522

522523
'expandtab' がオフ (既定値) のとき、Vimはインデントにできる限り多くの <Tab>
523524
使う。">><<" によって、空白のみで構成されたインデントを、<Tab> (と必要ならばい
@@ -959,6 +960,11 @@ NOTE: 以前のバージョンでは CTRL-V が特別に扱われていた。こ
959960
慣である)。
960961
`:retab!` も空白の連続を <Tab> 文字に変えてしまい、
961962
printf() の出力をめちゃくちゃにするかもしれない。
963+
|+vartabs| 機能が有効な場合、 単一の tabstop の代わり
964+
にコンマで分けられたタブ幅のリストが使用されるだろう。
965+
リストのそれぞれの値は 1 つの tabstop の幅を意味する
966+
が、最後の値だけは後続するすべての tabstop に適用され
967+
る。
962968
{Vi にはない}
963969

964970
*retab-example*
@@ -1404,6 +1410,55 @@ gww "gw" と同様にして現在行を整形する。 {Vi にはない}
14041410
外部プログラムによる整形処理には、'textwidth' や他のオプションは何の影響も与え
14051411
ない。
14061412

1413+
*format-formatexpr*
1414+
'formatexpr' オプションには、バッファの再整形を行う Vim script 関数を設定する
1415+
ことができる。整形はファイルの種類に強く依存するので、これは通常 |ftplugin|
1416+
発生するべきである。対応するスクリプトは実際に必要とされるときにだけ読み込ま
1417+
れ、かつそのスクリプト名は <filetype>format.vim とされるべきなので、|autoload|
1418+
スクリプトを使用することは理にかなっている。
1419+
1420+
例えば、Vim と共に配布され $VIMRUNTIME ディレクトリに配置されている XML ファイ
1421+
ルタイププラグインは、オプション 'formatexpr' を以下のように設定する: >
1422+
1423+
setlocal formatexpr=xmlformat#Format()
1424+
1425+
これは、xmlformat#Format() を定義している対応したスクリプトが以下のディレクト
1426+
リで見つかることを意味している:
1427+
`$VIMRUNTIME/autoload/xmlformat.vim`
1428+
1429+
以下は、選択されたテキストから末尾の空白を取り除くスクリプトの例である。これを
1430+
autoload ディレクトリに置くこと。例、~/.vim/autoload/format.vim: >
1431+
1432+
func! format#Format()
1433+
" 明示的な gq コマンドの場合だけ再整形する
1434+
if mode() != 'n'
1435+
" Vim の内部再整形に立ち戻る
1436+
return 1
1437+
endif
1438+
let lines = getline(v:lnum, v:lnum + v:count - 1)
1439+
call map(lines, {key, val -> substitute(val, '\s\+$', '', 'g')})
1440+
call setline('.', lines)
1441+
1442+
" 内部の整形は実行させない
1443+
return 0
1444+
endfunc
1445+
1446+
その後以下のように整形を有効にすることができる: >
1447+
setlocal formatexpr=format#Format()
1448+
>
1449+
Note: この関数は、挿入モードから呼ばれた場合に明示的に非ゼロを返す (基本的に
1450+
'textwidth' の制限を超えてテキストが挿入されることを意味する)。これは Vim に内
1451+
部の整形機能に立ち戻って再整形させることになる。
1452+
1453+
しかしながら、テキストを再整形するために |gq| コマンドが使用された場合、その関
1454+
数は選択された行を受け取り、それらの行から末尾の空白を取り除き、そして所定の位
1455+
置にそのテキストを配置しなおす。もし 1 つの行を複数行に分割しようとしている場
1456+
合、何か上書きしてしまわないよう注意すること。
1457+
1458+
挿入もしくは置換モードからのテキストの再整形を可能にしたい場合、関数が再帰的に
1459+
呼び出されることがあるため注意しなければならない。これをデバッグするためには、
1460+
'debug' オプションを設定することが役に立つ。
1461+
14071462
*right-justify*
14081463
テキストを右揃えするコマンドは、Vimには存在しない。"par" 等の外部コマンド (例:
14091464
"!}par" で段落の最後までを整形する) を実行したり、'formatprg' に "par" を指定

en/change.txt

Lines changed: 58 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
*change.txt* For Vim version 8.0. Last change: 2017 Feb 12
1+
*change.txt* For Vim version 8.1. Last change: 2018 May 12
22

33

44
VIM REFERENCE MANUAL by Bram Moolenaar
@@ -110,7 +110,7 @@ is an error when 'cpoptions' includes the 'E' flag.
110110
J Join [count] lines, with a minimum of two lines.
111111
Remove the indent and insert up to two spaces (see
112112
below). Fails when on the last line of the buffer.
113-
If [count] is too big it is reduce to the number of
113+
If [count] is too big it is reduced to the number of
114114
lines available.
115115

116116
*v_J*
@@ -446,7 +446,7 @@ This depends on the 'nrformats' option:
446446

447447
For decimals a leading negative sign is considered for incrementing/
448448
decrementing, for binary, octal and hex values, it won't be considered. To
449-
ignore the sign Visually select the number before using CTRL-A or CTRL-X.
449+
ignore the sign Visually select the number before using CTRL-A or CTRL-X.
450450

451451
For numbers with leading zeros (including all octal and hexadecimal numbers),
452452
Vim preserves the number of characters in the number when possible. CTRL-A on
@@ -533,6 +533,7 @@ If the 'shiftround' option is on, the indent is rounded to a multiple of
533533
If the 'smartindent' option is on, or 'cindent' is on and 'cinkeys' contains
534534
'#' with a zero value, shift right does not affect lines starting with '#'
535535
(these are supposed to be C preprocessor lines that must stay in column 1).
536+
This can be changed with the 'cino' option, see |cino-#|.
536537

537538
When the 'expandtab' option is off (this is the default) Vim uses <Tab>s as
538539
much as possible to make the indent. You can use ">><<" to replace an indent
@@ -986,6 +987,11 @@ This replaces each 'E' character with a euro sign. Read more in |<Char->|.
986987
this (that's a good habit anyway).
987988
`:retab!` may also change a sequence of spaces by
988989
<Tab> characters, which can mess up a printf().
990+
If the |+vartabs| feature is enabled then a list of
991+
tab widths separated by commas may be used in place of
992+
a single tabstop. Each value in the list represents
993+
the width of one tabstop, except the final value which
994+
applies to all following tabstops.
989995
{not in Vi}
990996

991997
*retab-example*
@@ -1444,6 +1450,55 @@ to the name of an external program for Vim to use for text formatting. The
14441450
'textwidth' and other options have no effect on formatting by an external
14451451
program.
14461452

1453+
*format-formatexpr*
1454+
The 'formatexpr' option can be set to a Vim Script function that performs
1455+
reformatting of the buffer. This should usually happen in an |ftplugin|,
1456+
since formatting is highly dependent on the type of file. It makes
1457+
sense to use an |autoload| script, so the corresponding script is only loaded
1458+
when actually needed and the script should be called <filetype>format.vim.
1459+
1460+
For example, the XML filetype plugin distributed with Vim in the $VIMRUNTIME
1461+
directory, sets the 'formatexpr' option to: >
1462+
1463+
setlocal formatexpr=xmlformat#Format()
1464+
1465+
That means, you will find the corresponding script, defining the
1466+
xmlformat#Format() function, in the directory:
1467+
`$VIMRUNTIME/autoload/xmlformat.vim`
1468+
1469+
Here is an example script that removes trailing whitespace from the selected
1470+
text. Put it in your autoload directory, e.g. ~/.vim/autoload/format.vim: >
1471+
1472+
func! format#Format()
1473+
" only reformat on explicit gq command
1474+
if mode() != 'n'
1475+
" fall back to Vims internal reformatting
1476+
return 1
1477+
endif
1478+
let lines = getline(v:lnum, v:lnum + v:count - 1)
1479+
call map(lines, {key, val -> substitute(val, '\s\+$', '', 'g')})
1480+
call setline('.', lines)
1481+
1482+
" do not run internal formatter!
1483+
return 0
1484+
endfunc
1485+
1486+
You can then enable the formatting by executing: >
1487+
setlocal formatexpr=format#Format()
1488+
>
1489+
Note: this function explicitly returns non-zero when called from insert mode
1490+
(which basically means, text is inserted beyond the 'textwidth' limit). This
1491+
causes Vim to fall back to reformat the text by using the internal formatter.
1492+
1493+
However, if the |gq| command is used to reformat the text, the function
1494+
will receive the selected lines, trim trailing whitespace from those lines and
1495+
put them back in place. If you are going to split single lines into multiple
1496+
lines, be careful not to overwrite anything.
1497+
1498+
If you want to allow reformatting of text from insert or replace mode, one has
1499+
to be very careful, because the function might be called recursively. For
1500+
debugging it helps to set the 'debug' option.
1501+
14471502
*right-justify*
14481503
There is no command in Vim to right justify text. You can do it with
14491504
an external command, like "par" (e.g.: "!}par" to format until the end of the

0 commit comments

Comments
 (0)