1

Regenerate nvim config

This commit is contained in:
2024-06-02 03:29:20 +02:00
parent 75eea0c030
commit ef2e28883d
5576 changed files with 604886 additions and 503 deletions

View File

@ -0,0 +1,96 @@
=============================================================================
COMPOUND RECIPES *sandwich-compound-recipes*
A compound recipe is one that contains multiple simple recipes. A simple
recipe could be a pair of parentheses `()` or braces `{}`, while a compound
recipe could be made up of all types of brackets `(),[],{}`, or both types of
quotes `'',""`.
sandwich.vim allows for the creation of compound recipes. This tutorial
demonstrates the creation of two compound recipes, brackets and quotes.
Users can adapt the code provided to customize their own compound recipes.
Compound text-objects~
By default, sandwich.vim can automatically search for a set of surroundings.
This functionality is provided by the `srb` and `sdb` |sandwich-keymappings|.
Under the hood, these mappings call |textobj#sandwich#auto()|.
This function |textobj#sandwich#auto()| also accepts an optional fourth
argument. If a list of (simple) recipes is given to the fourth argument, this
list is used instead.
We create a list of recipes for the brackets >
let g:sandwich_bracket_recipes = [
\ {'buns': ['{', '}'], 'nesting': 1, 'skip_break': 1},
\ {'buns': ['[', ']'], 'nesting': 1},
\ {'buns': ['(', ')'], 'nesting': 1},
\ ]
<
and another for the quotes >
let g:sandwich_quote_recipes = [
\ {'buns': ['"', '"'], 'quoteescape': 1, 'expand_range': 0, 'nesting': 0, 'linewise': 0},
\ {'buns': ["'", "'"], 'quoteescape': 1, 'expand_range': 0, 'nesting': 0, 'linewise': 0},
\ ]
<
Then, we pass these lists of (simple) recipes into |textobj#sandwich#auto()|
to create our text-objects. It is also convenient to access these
text-objects with key mappings. In this tutorial, we assign the mappings `ij,
aj` and `io, ao` to the brackets and quotes text-objects respectively >
onoremap <silent><expr> ij textobj#sandwich#auto('x', 'i', {}, g:sandwich_bracket_recipes)
onoremap <silent><expr> aj textobj#sandwich#auto('x', 'a', {}, g:sandwich_bracket_recipes)
xnoremap <silent><expr> ij textobj#sandwich#auto('x', 'i', {}, g:sandwich_bracket_recipes)
xnoremap <silent><expr> aj textobj#sandwich#auto('x', 'a', {}, g:sandwich_bracket_recipes)
onoremap <silent><expr> io textobj#sandwich#auto('x', 'i', {}, g:sandwich_quote_recipes)
onoremap <silent><expr> ao textobj#sandwich#auto('x', 'a', {}, g:sandwich_quote_recipes)
xnoremap <silent><expr> io textobj#sandwich#auto('x', 'i', {}, g:sandwich_quote_recipes)
xnoremap <silent><expr> ao textobj#sandwich#auto('x', 'a', {}, g:sandwich_quote_recipes)
<
With these, one can visually select the nearest pair of brackets with `vaj`.
In a similar manner, `dio` deletes the text between the two nearest quotes.
Compound recipes~
The next step is to add these text objects as compound recipes, and use them
with sandwich operators such as |<Plug>(operator-sandwich-delete)| and
|<Plug>(operator-sandwich-replace)| (default: `sd` and `sr`).
We define these compound recipes using external requisites (see
|textobj-sandwich-configuration| or |operator-sandwich-configuration|). The
text objects defined above and are passed into the `'external'` item, as seen
below >
let g:sandwich_compound_recipes = [
\ {
\ 'external': ['ij', 'aj'],
\ 'kind' : ['delete', 'replace', 'query'],
\ 'noremap' : 0,
\ 'input' : ['j'],
\ },
\ {
\ 'external': ['io', 'ao'],
\ 'kind' : ['delete', 'replace', 'query'],
\ 'noremap' : 0,
\ 'input' : ['o'],
\ },
\ ]
<
These recipes require an `'input'`, which we specify to be `'j'` and `'o'`
for brackets and quotes respectively.
Finally, we add these compound recipes to |g:sandwich#recipes|,
that is, the list of recipes used by sandwich.vim >
call extend(g:sandwich#recipes, g:sandwich_compound_recipes)
<
With these, one can delete the nearest pair of quotes simply with `sdo`.
Similarly, one can replace the nearest pair of brackets with `srj{char}`.
==============================================================================
vim:tw=78:ts=8:noet:ft=help:norl:

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,687 @@
*sandwich.jax* 日本語ヘルプ Last change:14-May-2022.
“挟まれた”テキストを編集するためのオペレータとテキストオブジェクトの詰め合わせ
です。
書いた人 : machakann <mckn{at}outlook.jp>
ライセンス : NYSL license
日本語 <http://www.kmonos.net/nysl/>
English (Unofficial) <http://www.kmonos.net/nysl/index.en.html>
必須要件: Vim 7.4 かそれ以降のバージョン
|+reltime| 機能 (任意)
|+float| 機能 (任意)
==============================================================================
CONTENTS *sandwich-contents*
QUICK START |sandwich-quick-start|
INTRODUCTION |sandwich-introduction|
KEYMAPPINGS |sandwich-keymappings|
CONFIGURATION |sandwich-configuration|
MAGICCHARACTERS |sandwich-magiccharacters|
FILETYPE RECIPES |sandwich-filetype-recipes|
FUNCTIONS |sandwich-functions|
MISCELLANEOUS |sandwich-miscellaneous|
vim-surround のキ-マッピングを使う
magicchar-f の挙動を変更する
==============================================================================
QUICK START *sandwich-quick-start*
*sandwich.vim* は文字列を括弧などで囲む/囲みを外す/囲みを置き換えることを目的
としたオペレータとテキストオブジェクトのセットです。例えば、(foo) や "bar" の
ような文字列が処理の対象になります。
囲む~
sa{motion/textobject}{addition} と、キー入力します。
例えば、 foo という単語にカーソルを合わせて saiw( と入力すると (foo) となりま
す。
囲みを外す~
sdb あるいは sd{deletion} とキー入力します。
例えば、 (foo) というテキストにカーソルを合わせて sdb あるいは sd( と入力する
と foo となります。 sdb という入力は自動的に囲まれたテキストを検索します。
囲みを置き換える~
srb{addition} あるいは sr{deletion}{addition} キー入力します。
例えば、 (foo) というテキストにカーソルを合わせて srb" あるいは sr(" と入力す
ると "foo" となります。
これだけ読めばこのプラグインを使うのに十分でしょう。もし、さらに興味がわいた方
、挙動を細かく変更したい方は続く記述およびオペレータとテキストオブジェクトそれ
ぞれのヘルプ |operator-sandwich| 、 |textobj-sandwich| をご覧ください。
==============================================================================
INTRODUCTION *sandwich-introduction*
このプラグインは文字列を括弧などで囲む/囲みを外す/囲みを置き換えるための機能を
提供します。オペレータ部分 |operator-sandwich| とテキストオブジェクト部分
|textobj-sandwich| の二つの部分からなり、これらが共働することにより機能を実現
します。また、同時にそれぞれが独立したオペレータ/テキストオブジェクトであるの
で、ほかのあらゆるオペレータ/テキストオブジェクトと組み合わせることもできます
。これらの機能は純粋にオペレータ及びテキストオブジェクトの枠組みを使って実装さ
れているので、いかなるライブラリにも依存することなく |.| コマンドによって繰り
返すことができます。
|sandwich.vim| の提供するキーマッピングおよびマッピング変更のための情報につい
ては|sandwich-keymappings|を参照してください。
|sandwich.vim|を構成する部品としての純粋なオペレータについての情報は
|operator-sandwich|のヘルプを参照してください。囲みを編集する機能をカスタマイ
ズするための情報もこちらのヘルプに詳細があります。
|sandwich.vim|を構成する部品としての純粋なテキストオブジェクトについての情報は
|textobj-sandwich| のヘルプを参照してください。テキストオブジェクトの挙動をカ
スタマイズするための情報もこちらのヘルプに詳細があります。
==============================================================================
KEYMAPPINGS *sandwich-keymappings*
このプラグインは以下のキーマッピングを提供します。
機能 デフォルトキーマッピング
--------------------------------------------------------------------------
囲む sa{motion/textobject}{addition} (ノーマル、ビジュアルモード)
-> |<Plug>(sandwich-add)|
囲みを外す
sd{deletion} (ノーマルモード)
sd (ビジュアルモード)
-> |<Plug>(sandwich-delete)|
sdb (ノーマルモード)
-> |<Plug>(sandwich-delete-auto)|
囲みを置き換える
sr{deletion}{addition} (ノーマルモード)
sr{addition} (ビジュアルモード)
-> |<Plug>(sandwich-replace)|
srb{addition} (ノーマルモード)
-> |<Plug>(sandwich-replace-auto)|
テキストオブジェクト
ib (オペレータ待機、ビジュアルモード)
-> |<Plug>(textobj-sandwich-auto-i)|
ab (オペレータ待機、ビジュアルモード)
-> |<Plug>(textobj-sandwich-auto-a)|
is (オペレータ待機、ビジュアルモード)
-> |<Plug>(textobj-sandwich-query-i)|
as (オペレータ待機、ビジュアルモード)
-> |<Plug>(textobj-sandwich-query-a)|
--------------------------------------------------------------------------
NOTE: 誤操作を防ぐため以下の設定を vimrc に追加することを強く推奨します。
>
nmap s <Nop>
xmap s <Nop>
<
|s| コマンドは |c|l| コマンドによって代替できます。
デフォルトのマッピングがお気に召さなければ*g:sandwich_no_default_key_mappings*
をあなたの vimrc で定義しておいてください。
>
let g:sandwich_no_default_key_mappings = 1
<
以下のコードはキーマッピングの開始キーを s から z に変える例です。
>
let g:sandwich_no_default_key_mappings = 1
" add
nmap za <Plug>(sandwich-add)
xmap za <Plug>(sandwich-add)
omap za <Plug>(sandwich-add)
" delete
nmap zd <Plug>(sandwich-delete)
xmap zd <Plug>(sandwich-delete)
nmap zdb <Plug>(sandwich-delete-auto)
" replace
nmap zr <Plug>(sandwich-replace)
xmap zr <Plug>(sandwich-replace)
nmap zrb <Plug>(sandwich-replace-auto)
<
必要ならテキストオブジェクトもマッピングしましょう。
>
" text-objects (if you need)
omap ib <Plug>(textobj-sandwich-auto-i)
xmap ib <Plug>(textobj-sandwich-auto-i)
omap ab <Plug>(textobj-sandwich-auto-a)
xmap ab <Plug>(textobj-sandwich-auto-a)
omap is <Plug>(textobj-sandwich-query-i)
xmap is <Plug>(textobj-sandwich-query-i)
omap as <Plug>(textobj-sandwich-query-a)
xmap as <Plug>(textobj-sandwich-query-a)
<
*<Plug>(sandwich-add)*
[count1] <Plug>(sandwich-add) [count2] {motion} {addition}
指定されたテキストを囲みます。
このキーマッピングは[count]を独特なルールで扱います。
[count1] は|<Plug>(sandwich-add)|に渡され [count1] 回囲みます。他方で
[count2] は通常通り {motion} に渡されます。どちらの[count]も省略可能で
す。{addition}は囲みを指定するキーで、例えば saiw( と入力すると単語を
丸括弧()で囲みます。
{Visual} [count] <Plug>(sandwich-add) {addition}
[count]回ヴィジュアル選択した範囲を囲みます。
<Plug>(sandwich-add)はノーマルモード、ヴィジュアルモード、オペレータ待
機モードにマップ可能です。デフォルトでは sa にマップされています。
>
nmap sa <Plug>(sandwich-add)
xmap sa <Plug>(sandwich-add)
omap sa <Plug>(sandwich-add)
<
*<Plug>(sandwich-delete)*
[count] <Plug>(sandwich-delete) {deletion}
カーソルから最も近い{deletion}に指定される囲みを外します。例えば、
sd( と入力するとカーソルから最も近い対応する丸括弧()を削除します。
>
(foo) -> foo
<
[count]を指定するとカーソルから[count]番目に近い囲みを削除します。
>
(foo(bar)baz) cursor is on "bar"
-- sd( --> (foobarbaz)
-- 2sd( --> foo(bar)baz
<
{Visual} [count] <Plug>(sandwich-delete)
ヴィジュアル選択範囲の両端にある連続した囲みを[count]回外します。
<Plug>(sandwich-delete)はノーマルモード、ヴィジュアルモードにマップ可
能です。デフォルトでは sd にマップされています。
>
nmap sd <Plug>(sandwich-delete)
xmap sd <Plug>(sandwich-delete)
<
*<Plug>(sandwich-delete-auto)*
[count] <Plug>(sandwich-delete-auto)
カーソルから最も近い囲みを自動的に検索して外します。
[count]を指定するとカーソルから[count]番目に近い囲みを削除します。
>
[foo(bar)baz] cursor is on "bar"
-- sdb --> [foobarbaz]
-- 2sdb --> foo(bar)baz
<
<Plug>(sandwich-delete-auto)はノーマルモードにマップ可能です。
デフォルトでは sdb にマップされています。
>
nmap sdb <Plug>(sandwich-delete-auto)
<
*<Plug>(sandwich-replace)*
[count] <Plug>(sandwich-replace) {deletion} {addition}
カーソルから最も近い{deletion}に指定される囲みを{addition}に指定される
囲みに置換します。例えば、sr([ と入力するとカーソルから最も近い対応す
る丸括弧()を角括弧[]に置換します。
>
(foo) -> [foo]
<
[count]を指定するとカーソルから[count]番目に近い囲みを置換します。
>
(foo(bar)baz) cursor is on "bar"
-- sr([ --> (foo[bar]baz)
-- 2sr([ --> [foo(bar)baz]
<
{Visual} [count] <Plug>(sandwich-replace) {addition}
ヴィジュアル選択範囲の両端にある連続した囲みを[count]回置換します。
<Plug>(sandwich-replace)はノーマルモード、ヴィジュアルモードにマップ可
能です。デフォルトでは sr にマップされています。
>
nmap sr <Plug>(sandwich-replace)
xmap sr <Plug>(sandwich-replace)
<
*<Plug>(sandwich-replace-auto)*
[count] <Plug>(sandwich-replace-auto) {addition}
カーソルから最も近い囲みを自動的に検索して置換します。
[count]を指定するとカーソルから[count]番目に近い囲みを削除します。
>
[foo(bar)baz] cursor is on "bar"
-- srb{ --> [foo{bar}baz]
-- 2srb{ --> {foo(bar)baz}
<
<Plug>(sandwich-replace-auto)はノーマルモードにマップ可能です。
デフォルトでは srb にマップされています。
>
nmap srb <Plug>(sandwich-replace-auto)
<
==============================================================================
CONFIGURATION *sandwich-configuration*
括弧などのセットとその性質に依るオプションをまとめた情報をレシピ "recipe" と呼
びます。一つ一つのレシピは |Dictionary| で、これらを集めた |list| がオペレータ
やテキストオブジェクトの動作を決めます。 |g:sandwich#default_recipes| はその一
つで、 |operator-sandwich| と |textobj-sandwich| の両方から参照されます。多く
の場合、この情報は共有したほうが便利であるためです。 |g:sandwich#recipes| がユ
ーザーによって定義された場合こちらがかわりに参照されます。デフォルト設定の
|g:sandwich#default_recipes| は |:echo| コマンドによって確認できます。
>
:echo g:sandwich#default_recipes
<
上記に加え、 |g:operator#sandwich#recipes| と |g:textobj#sandwich#recipes| も
レシピを持つことができます。これらは |operator-sandwich| と |textobj-sandwich|
のそれぞれからしか参照されません。固有のレシピをおきたい場合に使いましょう。
レシピの細かい仕様については、オペレータ及びテキストオブジェクトのヘルプ、
|operator-sandwich-configuration| 及び |textobj-sandwich-configuration| をご覧
ください。
g:sandwich#recipes *g:sandwich#recipes*
|operator-sandwich| と |textobj-sandwich| の両方から参照されるレシピの
リストです。もし存在しなければ |g:sandwich#default_recipes| がかわりに
つかわれます。
*b:sandwich_recipes*
|b:sandwich_recipes| が存在する場合は、 |g:sandwich#recipes| のかわり
にそちらが使われます。これはバッファについてローカルな値なので、ファイ
ルタイプ固有な設定が増えすぎた時に使うと便利かもしれません。
g:sandwich#default_recipes *g:sandwich#default_recipes*
デフォルトで用意されたレシピのリストです。 |g:sandwich#recipes| が存在
すれば、そちらがかわりにつかわれます。
この変数は変更を禁止されていますが、 |g:sandwich#recipes| を宣言する際
に必要ならコピーすることができます。
>
:let g:sandwich#recipes = deepcopy(g:sandwich#default_recipes)
<
デフォルトレシピについて~
`(`, `)`
`[`, `]`
`{`, `}`
`<`, `>`
開き/閉じ括弧は同様に機能します。例えば、 `saiw(` と `saiw)` は同様の
結果を与えます。
>
foo -> (foo)
<
`sd(` と `sd)` はこの反対のことをします。
------------------------------------------------------------------------------
`'`
`"`
クオーテーションで文字列を囲みます。
>
foo -> 'foo'
<
クオーテーションによる囲みを消す場合 `quoteescape` オプションが考慮さ
れます。また、両端が同じ行の中にある必要があります。
------------------------------------------------------------------------------
`<Space>`
スペース囲みを消す場合、連続するスペースを一度に消します。
------------------------------------------------------------------------------
`t`, `T`
`f`, `F`
`i`, `I`
|sandwich-magiccharacters| をご覧ください。
------------------------------------------------------------------------------
Global options~
g:sandwich#timeout *g:sandwich#timeout*
この変数に偽値が設定されている場合は、オペレータやテキストオブジェクト
は一つのレシピを指定する完全な入力がなされるまで待ちます。例えば、下記
のレシピを用意します。
>
let g:sandwich#recipes = [
\ {'buns': ['for {', '}'], 'nesting': 1, 'input': ['bf']}
\ {'buns': ['if {', '}'], 'nesting': 1, 'input': ['bi']}
\ {'buns': ['else {', '}'], 'nesting': 1, 'input': ['be']}
\ ]
<
このオプションが真の場合は `saiwb` とタイプして少し待つと、オペレータ
はタイムアウトのため単語を `b` で囲みます。しかし、偽の場合は一つのレ
シピを指定する入力が完成するまで待ちます。この変数はオペレータとテキス
トオブジェクトの両方に効果を及ぼします。|g:operator#sandwich#timeout|
や |g:textobj#sandwich#timeout| が存在する場合はそれらが優先的に使われ
ます。この変数が定義されていなければ 'timeout' オプションが代わりに参
照されます。
関連:|g:sandwich#timeoutlen|
g:sandwich#timeoutlen *g:sandwich#timeoutlen*
入力に前方一致で重複するレシピが存在する場合に次のキーシーケンスを待つ
時間をミリ秒単位で指定します。
>
let g:sandwich#recipes = [
\ {'buns': ['(', ')']}
\ {'buns': ['((', '))']}
\ ]
<
saiw( とキー入力するとオペレータは次に ( が入力されるかこの時間だけ待
ちます。この間にもう一度 ( を押下すると '((' と '))' のレシピが使われ
るでしょう。キーの押下なしでこの時間が過ぎると '(' と ')' のレシピが使
われるでしょう。この変数はオペレータとテキストオブジェクトの両方に効果
を及ぼします。|g:operator#sandwich#timeoutlen| や
|g:textobj#sandwich#timeout| が存在する場合はそれらが優先的に使われま
す。この変数が定義されていなければ 'timeoutlen' が代わりに参照されま
す。
タイムアウト機能(|g:operator#sandwich#timeout|,
|g:textobj#sandwich#timeout|, |g:sandwich#timeout|, 'timeout')がオフの
場合はこのオプションは無視されます。
g:sandwich#input_fallback *g:sandwich#input_fallback*
このオプションは囲みを追加・削除・置換するためのユーザーの入力に合致す
るレシピが存在しない場合の挙動を制御します。このオプションが真のとき、
ユーザーの入力に合致するレシピがなければ、入力された文字自体を追加・削
除・置換の対象とします。例えば、a という入力に合致するレシピが存在しな
くても saiwa と入力すると単語を a で囲みます。
>
foo -> afooa
<
この動作が必要ない場合はこのオプションに偽値を設定します。
>
let g:sandwich#input_fallback = 0
<
==============================================================================
MAGICCHARACTERS *sandwich-magiccharacters*
sandwich.vim は {addition}/{deletion} を決めるためにユーザーに入力を促します。
これは例えば `(` が `()` のペアを、 `"` が `""` のペアを指しますが、より特殊な
用途のための入力がいくつか存在します。
f~
F~
関数で囲みます。例えば `saiwf` と入力すると `f` キーの入力の後に関数名
の入力を求められます。関数名を入力し <CR> キーを押すと、その関数名付き
の丸括弧でテキストオブジェクトを囲みます。関数名の入力中、 <Tab> キー
で現在のバッファから関数名を補完できます。
>
arg -- saiwffunc<CR> --> func(arg)
<
逆に `sdf` は関数囲みを削除します。
>
func(arg) -- sdf --> arg
<
関数がネストしている場合、 `sdf` はカーソル下の関数囲みを削除し、
`sdF` は外側の関数囲みを削除します。
>
cursor is on 'func2':
func1(func2(arg)) -- sdf --> func1(arg)
-- sdF --> func2(arg)
<
i~
I~
その時だけの (`I`nstant) 囲みを定義します。 `saiwi` はユーザーに前方囲
みと後方囲みの入力を求めます。例えば、 `saiwifoo<CR>bar<CR>` という
入力はカーソル下の単語を `foo` と `bar` で囲みます。入力中は <Tab>
キーにより現在のバッファから簡単な単語補完を使えます。反対に `sdi` は
任意の入力された囲みを削除します。つまり、 `sdifoo<CR>bar<CR>` は
`foowordbar` という文字列を `word` にします。これは |.| コマンドによっ
て繰り返すことができるので、編集対象の文字列が多く存在する場合に便利か
もしれません。
`sa{textobj}I` や `sdI` は最後の入力を再利用します。
t~
T~
`t` および `T` は HTML 様のタグの編集を支援します。 `saiwt` はユーザー
にタグの要素名の入力を促し、そのタグで囲みます。 `saiwT` も同様に機能
します。
>
word -- saiwtp<CR> --> <p>word</p>
<
`sdt` は直近のタグ囲みを削除します。 `sdT` も同様に機能します。
>
<p>word</p> -- sdt --> word
<
`t` と `T` は囲みを置換するときに別のふるまいをします。
`srtt` はタグの要素名のみを置き換え、属性等は変更しません。
`srTT` はタグ全体を置き換えます。
==============================================================================
FILETYPE RECIPES *sandwich-filetype-recipes*
Sandwich.vim にはファイルタイプに固有のレシピもあります。これらは 'filetype'
オプションが特定の値のときのみ読み込まれ、有効になります。またこれらはユーザー
設定を上書きしないので、必要なものだけ残して使うとよいでしょう。設定の本体は
ftplugin/{filetype}/sandwich.vim に記述されています。
もし、それらのファイルを読み込んでほしくない場合は
`g:sandwich_no_{filetype}_ftplugin` に真値を設定しておいてください。例えば、
tex 固有のレシピが必要ない場合、次の一行を vimrc に加えます。
>
let g:sandwich_no_tex_ftplugin = 1
<
------------------------------------------------------------------------------
plaintex~
tex~
>
囲み 入力
`{text}' u'
“{text}” u"
„{text}“ U"
ug
u,
«{text}» u<
uf
`{text}' l'
l`
``{text}'' l"
"`{text}"' L"
,,{text}`` l,
<<{text}>> l<
\{{text}\} \{
\[{text}\] \[
\left({text}\right) m(
\left[{text}\right] m[
\left|{text}\right| m|
\left\{{text}\right\} m{
\left\langle {text}\right\rangle m<
< 'm' 始まりの入力で挿入される囲みはすべて `ma` という入力で削除すること
ができます。例えば `sdma` のように使います。
>
\big({text}\big) M(
\big[{text}\big] M[
\big|{text}\big| M|
\big\{{text}\big\} M{
\big\langle {text}\big\rangle M<
\begingroup{text}\endgroup gr
\gr
\toprule{text}\bottomrule tr
br
\tr
\br
\{input}{{text}} c
< このレシピはユーザーに入力を求め、入力されたテキストで {input} を置き
換えます。
>
\begin{{input}}{text}\end{{input}} e
< このレシピはユーザーに入力を求め、入力されたテキストで {input} を置き
換えます。<Tab> キーにより {input} の入力を補完することができます。
この時、補完候補は `g:sandwich#filetype#tex#environments`
(あるいは存在すれば `b:sandwich#filetype#tex#environments`) から読み込
まれます。
==============================================================================
FUNCTIONS *sandwich-functions*
sandwich#util#addlocal({recipes}) *sandwich#util#addlocal()*
レシピのリスト {recipes} をそのバッファにのみ有効な設定として追加しま
す。この際、既存のグローバルな設定はそのまま受け継がれます。この関数は
グローバルな設定をきれいに保ったままファイルタイプに特有な設定を追加す
る、などの用途に使えます。{recipes} はレシピのリスト |List| である点は
注意してください。
>
autocmd FileType python call sandwich#util#addlocal([
\ {'buns': ['"""', '"""'], 'nesting': 0, 'input': ['3"']},
\ ])
<
==============================================================================
MISCELLANEOUS *sandwich-miscellaneous*
vim-surround のキーマッピングを使う~
vim-surround (vim script #1697) と同じキーマッピングが使いたければ次の
行を vimrc に追加してください。
>
runtime macros/sandwich/keymap/surround.vim
<
NOTE: surround.vim とは違い、 `(` と `)` の入力は同じように機能しま
す。もし、オリジナルの surround.vim のように `(` の入力により、
空白を含んだ括弧で囲みたい場合は次のように書きます。
>
runtime macros/sandwich/keymap/surround.vim
let g:sandwich#recipes += [
\ {'buns': ['{ ', ' }'], 'nesting': 1, 'match_syntax': 1,
\ 'kind': ['add', 'replace'], 'action': ['add'], 'input': ['{']},
\
\ {'buns': ['[ ', ' ]'], 'nesting': 1, 'match_syntax': 1,
\ 'kind': ['add', 'replace'], 'action': ['add'], 'input': ['[']},
\
\ {'buns': ['( ', ' )'], 'nesting': 1, 'match_syntax': 1,
\ 'kind': ['add', 'replace'], 'action': ['add'], 'input': ['(']},
\
\ {'buns': ['{\s*', '\s*}'], 'nesting': 1, 'regex': 1,
\ 'match_syntax': 1, 'kind': ['delete', 'replace', 'textobj'],
\ 'action': ['delete'], 'input': ['{']},
\
\ {'buns': ['\[\s*', '\s*\]'], 'nesting': 1, 'regex': 1,
\ 'match_syntax': 1, 'kind': ['delete', 'replace', 'textobj'],
\ 'action': ['delete'], 'input': ['[']},
\
\ {'buns': ['(\s*', '\s*)'], 'nesting': 1, 'regex': 1,
\ 'match_syntax': 1, 'kind': ['delete', 'replace', 'textobj'],
\ 'action': ['delete'], 'input': ['(']},
\ ]
<
ノーマルモードにおける `ys`, `yss`, `yS`, `ds`, `cs` 及び、ビジュアル
モードにおける `S` が使用できます。また、 vim-surround にはありません
が `dss` と `css` も使用できます。これらは `ds` と `cs` に似ていますが
削除/置換対象となる括弧やクオーテーションを自動的に選択します。
さらに vim-sandwich は便利なテキストオブジェクトが独立して使用できま
す。ぜひ試してみてください。
* ユーザーの入力に従い、括弧や同じ文字に囲まれた領域を選択
|<Plug>(textobj-sandwich-query-i)|, |<Plug>(textobj-sandwich-query-a)|
>
xmap is <Plug>(textobj-sandwich-query-i)
xmap as <Plug>(textobj-sandwich-query-a)
omap is <Plug>(textobj-sandwich-query-i)
omap as <Plug>(textobj-sandwich-query-a)
<
* 最も近い括弧に囲まれた領域を選択
|<Plug>(textobj-sandwich-auto-i)|, |<Plug>(textobj-sandwich-auto-a)|
>
xmap iss <Plug>(textobj-sandwich-auto-i)
xmap ass <Plug>(textobj-sandwich-auto-a)
omap iss <Plug>(textobj-sandwich-auto-i)
omap ass <Plug>(textobj-sandwich-auto-a)
<
* ユーザーの入力に従い、同じ文字に囲まれた領域を選択
|<Plug>(textobj-sandwich-literal-query-i)|,
|<Plug>(textobj-sandwich-literal-query-a)|
>
xmap im <Plug>(textobj-sandwich-literal-query-i)
xmap am <Plug>(textobj-sandwich-literal-query-a)
omap im <Plug>(textobj-sandwich-literal-query-i)
omap am <Plug>(textobj-sandwich-literal-query-a)
<
------------------------------------------------------------------------------
magicchar-f の挙動を変更する~
`magicchar-f` は単純な関数呼び出しを削除できます。
>
func(arg) -- sdf --> arg
<
もし、もっと複雑なパターンにも対応させたい場合、例えば、
>
obj.method(arg) -- sdf --> arg
<
このような場合に対応させるには `g:sandwich#magicchar#f#patterns` か
`b:sandwich_magicchar_f_patterns` を使います。 これらは次のようなパターンのリ
ストです。
>
let g:sandwich#magicchar#f#patterns = [
\ {
\ 'header' : '\<\h\k*',
\ 'bra' : '(',
\ 'ket' : ')',
\ 'footer' : '',
\ },
\ ]
<
四つの文字列はすべて正規表現パターンで、開括弧の前の文字列、開括弧、閉括弧、
閉括弧の後に続く文字列にマッチします。すなわち、先に述べたようなパターンに対応
するには以下のような設定をします。
>
let g:sandwich#magicchar#f#patterns = [
\ {
\ 'header' : '\<\%(\h\k*\.\)*\h\k*',
\ 'bra' : '(',
\ 'ket' : ')',
\ 'footer' : '',
\ },
\ ]
<
`b:sandwich_magicchar_f_patterns` はファイルタイプ毎の設定を定義するのに使えま
す。
>
augroup sandwich-ft-python
autocmd Filetype python let b:sandwich_magicchar_f_patterns = [
\ {
\ 'header' : '\<\%(\h\k*\.\)*\h\k*',
\ 'bra' : '(',
\ 'ket' : ')',
\ 'footer' : '',
\ },
\ ]
augroup END
<
デフォルトの設定は `g:sandwich#magicchar#f#default_patterns` にあります。
==============================================================================
vim:tw=78:ts=8:ft=help:norl:noet:

View File

@ -0,0 +1,699 @@
*sandwich.txt* Last change:03-Jul-2022.
The set of operator and textobject plugins to edit sandwiched textobjects.
Author : machakann <mckn{at}outlook.jp>
License : NYSL license
Japanese <http://www.kmonos.net/nysl/>
English (Unofficial) <http://www.kmonos.net/nysl/index.en.html>
Requirement: Vim 7.4 or higher
|+reltime| feature (optional)
|+float| feature (optional)
==============================================================================
CONTENTS *sandwich-contents*
QUICK START |sandwich-quick-start|
INTRODUCTION |sandwich-introduction|
KEYMAPPINGS |sandwich-keymappings|
CONFIGURATION |sandwich-configuration|
MAGICCHARACTERS |sandwich-magiccharacters|
FILETYPE RECIPES |sandwich-filetype-recipes|
FUNCTIONS |sandwich-functions|
MISCELLANEOUS |sandwich-miscellaneous|
Introduce vim-surround keymappings
Customize the behavior of magicchar-f
Any way to make a recipe deletes kinds of parentheses and brackets?
==============================================================================
QUICK START *sandwich-quick-start*
*sandwich.vim* is the set of operator and textobject plugins to
add/delete/replace surroundings of a sandwiched textobject, like (foo), "bar".
add~
Press sa{motion/textobject}{addition}.
For example, saiw( makes foo to (foo).
delete~
Press sdb or sd{deletion}.
For example, sdb or sd( makes (foo) to foo.
sdb searchs a set of surrounding automatically.
replace~
Press srb{addition} or sr{deletion}{addition}.
For example, srb" or sr(" makes (foo) to "foo".
Now you already know enough about sandwich.vim. If you want more,
read this help and each help documents of operator/textobject,
|operator-sandwich| and |textobj-sandwich|.
==============================================================================
INTRODUCTION *sandwich-introduction*
This plugin provides functions to add/delete/replace surroundings of
sandwiched texts. These functions are implemented genuinely by utilizing
operator/textobject framework. Their action can be repeated by |.| command
without any dependency.
Refer to the |sandwich-keymappings| for the key mappings supplied by
|sandwich.vim|. It also explains how to change key mappings for your
preference.
Refer to the |operator-sandwich| for the details of the genuine operators.
It also explains how to customize the functions to edit surroundings.
Refer to the |textobj-sandwich| for the details of the genuine textobjects.
It also explains how to customize the behavior of textobjects.
==============================================================================
KEYMAPPINGS *sandwich-keymappings*
This plugin defines the following keymappings.
function default keymappings
--------------------------------------------------------------------------
add sa{motion/textobject}{addition} (normal and visual mode)
-> |<Plug>(sandwich-add)|
delete
sd{deletion} (normal mode)
sd (visual mode)
-> |<Plug>(sandwich-delete)|
sdb (normal mode)
-> |<Plug>(sandwich-delete-auto)|
replace
sr{deletion}{addition} (normal mode)
sr{addition} (visual mode)
-> |<Plug>(sandwich-replace)|
srb{addition} (normal mode)
-> |<Plug>(sandwich-replace-auto)|
textobjct
ib (operator-pending and visual mode)
-> |<Plug>(textobj-sandwich-auto-i)|
ab (operator-pending and visual mode)
-> |<Plug>(textobj-sandwich-auto-a)|
is (operator-pending and visual mode)
-> |<Plug>(textobj-sandwich-query-i)|
as (operator-pending and visual mode)
-> |<Plug>(textobj-sandwich-query-a)|
--------------------------------------------------------------------------
NOTE: To prevent unintended operation, the following setting is strongly
recommended to add to your vimrc.
>
nmap s <Nop>
xmap s <Nop>
<
|s| could be easily replaced by |c|l| commands.
If you don't need the default mappings, define
*g:sandwich_no_default_key_mappings* in your vimrc.
>
let g:sandwich_no_default_key_mappings = 1
<
The following code snippet shows how to change the trigger key from s to z.
>
let g:sandwich_no_default_key_mappings = 1
" add
nmap za <Plug>(sandwich-add)
xmap za <Plug>(sandwich-add)
omap za <Plug>(sandwich-add)
" delete
nmap zd <Plug>(sandwich-delete)
xmap zd <Plug>(sandwich-delete)
nmap zdb <Plug>(sandwich-delete-auto)
" replace
nmap zr <Plug>(sandwich-replace)
xmap zr <Plug>(sandwich-replace)
nmap zrb <Plug>(sandwich-replace-auto)
<
Additionally, map textobjects if you need.
>
" text-objects (if you need)
omap ib <Plug>(textobj-sandwich-auto-i)
xmap ib <Plug>(textobj-sandwich-auto-i)
omap ab <Plug>(textobj-sandwich-auto-a)
xmap ab <Plug>(textobj-sandwich-auto-a)
omap is <Plug>(textobj-sandwich-query-i)
xmap is <Plug>(textobj-sandwich-query-i)
omap as <Plug>(textobj-sandwich-query-a)
xmap as <Plug>(textobj-sandwich-query-a)
<
*<Plug>(sandwich-add)*
[count1] <Plug>(sandwich-add) [count2] {motion} {addition}
Wrap an assigned text on the buffer.
This key mapping handles [count] uniquely.
[count1] is given to |<Plug>(sandwich-add)| and thus surround the text
[count1] times. On the other hand, [count2] is passed to {motion} as
usually. Both of those [count]s are optional. The {addition} is the
key to specify the surroundings; for example, an input saiw( wraps a
word by parentheses().
{Visual} [count] <Plug>(sandwich-add) {addition}
Wrap the visual-selected text [count] times.
<Plug>(sandwich-add) is available in normal, visual, and
operator-pending mode. It is mapped at sa in default.
>
nmap sa <Plug>(sandwich-add)
xmap sa <Plug>(sandwich-add)
omap sa <Plug>(sandwich-add)
<
*<Plug>(sandwich-delete)*
[count] <Plug>(sandwich-delete) {deletion}
Delete a pair of surroundings nearest to the cursor specified by
{deletion}. For example, an input sd( deletes a pair of parentheses()
nearest to the cursor.
>
(foo) -> foo
<
Delete the [count]th closest surroundings if [count] is given.
>
(foo(bar)baz) cursor is on "bar"
-- sd( --> (foobarbaz)
-- 2sd( --> foo(bar)baz
<
{Visual} [count] <Plug>(sandwich-delete)
Delete the successive surroundings at the both ends of the visually
selected text. Delete [count] times if [count] is given.
<Plug>(sandwich-delete) is available in normal and visual mode. It is
mapped at sd in default.
>
nmap sd <Plug>(sandwich-delete)
xmap sd <Plug>(sandwich-delete)
<
*<Plug>(sandwich-delete-auto)*
[count] <Plug>(sandwich-delete-auto)
Delete the [count]th closest surroundings from the cursor.
>
[foo(bar)baz] cursor is on "bar"
-- sdb --> [foobarbaz]
-- 2sdb --> foo(bar)baz
<
<Plug>(sandwich-delete-auto) is available in normal mode. It is mapped
at sdb in default.
>
nmap sdb <Plug>(sandwich-delete-auto)
<
*<Plug>(sandwich-replace)*
[count] <Plug>(sandwich-replace) {deletion} {addition}
Replace the closest surroundings from the cursor specified by
{deletion} to another surroundings specified by {addition}. For
example, an input sr([ replaces a pair of parentheses() to a pair of
square brackets[].
>
(foo) -> [foo]
<
Replace the [count]th closest surroundings if [count] is given.
>
(foo(bar)baz) cursor is on "bar"
-- sr([ --> (foo[bar]baz)
-- 2sr([ --> [foo(bar)baz]
<
{Visual} [count] <Plug>(sandwich-replace) {addition}
Replace the successive surroundings at the both ends of the visually
selected text to another surroundings specified by {addition}.
Replace [count] times if [count] is given.
<Plug>(sandwich-replace) is available in normal and visual mode. It is
mapped at sr in default.
>
nmap sr <Plug>(sandwich-replace)
xmap sr <Plug>(sandwich-replace)
<
*<Plug>(sandwich-replace-auto)*
[count] <Plug>(sandwich-replace-auto) {addition}
Replace the [count]th closest surroundings from the cursor to another
surroundings specified by {addition}.
>
[foo(bar)baz] cursor is on "bar"
-- srb{ --> [foo{bar}baz]
-- 2srb{ --> {foo(bar)baz}
<
<Plug>(sandwich-replace-auto) is available in normal mode. It is
mapped at srb in default.
>
nmap srb <Plug>(sandwich-replace-auto)
<
==============================================================================
CONFIGURATION *sandwich-configuration*
A set of surroundings and options for it is called "recipe". Each recipe is a
dictionary and the |list|s of recipes determines the operator's behavior and
textobject's behavior. |g:sandwich#default_recipes| is one of the |list|s of
recipes. This is shared to be used by |operator-sandwich| and
|textobj-sandwich| since it is convenient in many cases. If
|g:sandwich#recipes| is defined by user, it is employed alternatively. The
default recipes |g:sandwich#default_recipes| can be checked by |:echo|
command.
>
:echo g:sandwich#default_recipes
<
Besides them, |g:operator#sandwich#recipes| and |g:textobj#sandwich#recipes|
can be used. They are used only by |operator-sandwich| and |textobj-sandwich|
respectively.
About the contents of a recipe, please see |operator-sandwich-configuration|
and |textobj-sandwich-configuration|.
g:sandwich#recipes *g:sandwich#recipes*
This is one of the lists of recipes which is referred from both
|operator-sandwich| and |textobj-sandwich|. If this list does not
exist, |g:sandwich#default_recipes| is used.
*b:sandwich_recipes*
If |b:sandwich_recipes| exists, it would be used instead of
|g:sandwich#recipes|. This is buffer local, thus it might be
convenient to manage too many filetype-specific recipes.
g:sandwich#default_recipes *g:sandwich#default_recipes*
This is a list of recipes which is prepared in default. If
|g:sandwich#recipes| exists, it will be used instead.
This variable is locked usually, but it can be copied when you declare
|g:sandwich#recipes| if you need.
>
:let g:sandwich#recipes = deepcopy(g:sandwich#default_recipes)
<
Notes on default recipes~
`(`, `)`
`[`, `]`
`{`, `}`
`<`, `>`
Both open/close braces behave as same. For example, `saiw(` and `saiw)`
result in the same text.
>
foo -> (foo)
<
`sd(` and `sd)` do the opposite.
------------------------------------------------------------------------------
`'`
`"`
Wrap a text by quotes.
>
foo -> 'foo'
<
When deleting a pair of quotes, 'quoteescape' option is considered.
The pair of quotes are searched only in a same line.
------------------------------------------------------------------------------
`<Space>`
When deleting a pair of spaces, successive spaces are deleted at a
time.
------------------------------------------------------------------------------
`t`, `T`
`f`, `F`
`i`, `I`
See |sandwich-magiccharacters|.
------------------------------------------------------------------------------
Global options~
g:sandwich#timeout *g:sandwich#timeout*
If this option is a falsy value, the operators and the
query-textobject will wait for subsequent inputs until the complete
key sequence has been received to specify a recipe. For example, with
the following recipes,
>
let g:sandwich#recipes = [
\ {'buns': ['for {', '}'], 'nesting': 1, 'input': ['bf']}
\ {'buns': ['if {', '}'], 'nesting': 1, 'input': ['bi']}
\ {'buns': ['else {', '}'], 'nesting': 1, 'input': ['be']}
\ ]
<
type `saiwb` and a while later the operator eagerly wrap a word with
`b` if this option is true. The operators wait next input until a
recipe is specified if this option is false. This option takes effect
both on the operators and the query-textobject.
|g:operator#sandwich#timeout| or |g:textobj#sandwich#timeout| takes
priority over this option if it exists. If this has not been defined,
'timeout' option is referred. See |g:sandwich#timeoutlen| also.
g:sandwich#timeoutlen *g:sandwich#timeoutlen*
The time in milli seconds that waits for a key code or mapped key
sequence to complete. If there are recipes overlapped, this option is
used. Assume that the following recipes are prepared:
>
let g:sandwich#recipes = [
\ {'buns': ['(', ')']}
\ {'buns': ['((', '))']}
\ ]
<
after pressing saiw(, the operator waits in the time. If you press one
more ( in the time, then a recipe for '((' and '))' is decided to use.
No keypress has come through the time a recipe for '(' and ')' is
settled. This option takes effect both on the operators and the
query-textobject. |g:operator#sandwich#timeoutlen| or
|g:textobj#sandwich#timeoutlen| takes priority over this option if it
exists. If this variable has not been defined, 'timeoutlen' option is
referred.
When the timeout option (|g:operator#sandwich#timeout|,
|g:textobj#sandwich#timeout|, |g:sandwich#timeout|, 'timeout') is off,
this option is ignored.
g:sandwich#input_fallback *g:sandwich#input_fallback*
This bool option controls the behavior when no recipe matches with
user input to add/delete/replace surroundings. If this option is true
and no recipe matches with user input, the user input character itself
is used as the surroundings for add/delete/replace. For example, even
if there is no recipe associated with input `a` the key sequence
`saiwa` wraps a word with `a`.
>
foo -> afooa
<
Set falthy value to this option if this behavior is not desired.
>
let g:sandwich#input_fallback = 0
<
==============================================================================
MAGICCHARACTERS *sandwich-magiccharacters*
Sandwich.vim requests user to input keys for determination of
{addtion}/{deletion}. Usually it is something like `(` for `()` pair or
`"` for `""` pair, but there is several functional inputs for cumbersome
editings. It might be helpful for your work, give it a try!
f~
F~
Press `saiwf` to surround a word by function. After inputting `f` key,
user would be requested to input function name and press <CR>, then
the target textobject would be surrounded by parenthesis with the
function name. <Tab> key completes function names from the current
buffer in input.
>
arg -- saiwffunc<CR> --> func(arg)
<
The key sequence `sdf`, conversely, deletes function surrounding.
>
func(arg) -- sdf --> arg
<
In case of nested functions, `sdf` deletes the function under the
cursor while `sdF` deletes the function surrounding.
>
cursor is on 'func2':
func1(func2(arg)) -- sdf --> func1(arg)
-- sdF --> func2(arg)
<
i~
I~
It realizes to define `I`nstant surroundings. `saiwi` ask user for
inputting former and latter surroundings. For example,
`saiwifoo<CR>bar<CR>` makes a word surrounded by `foo` and `bar`.
<Tab> key completes words from the current buffer, just simply.
On the other hand `sdi` deletes arbitrary surroundings. For example,
`sdifoo<CR>bar<CR>` makes `foowordbar` to `word`, the inputs would be
interpreted as regular expressions. This is useful when a lot of
targets are there because the action could be repeated by |.| command.
`sa{textobj}I`, `sdI` reuse the last inputs.
t~
T~
The inputs `t` and `T` support to edit HTML style tags. `saiwt` ask
user to input a name of element, then a textobject would be surrounded
by the tag. `saiwT` works as same.
>
word -- saiwtp<CR> --> <p>word</p>
<
`sdt` deletes the nearest tag surroundings. `sdT` works as same.
>
<p>word</p> -- sdt --> word
<
`t` and `T` works differently only when replacing surroundings.
`srtt` replaces only the name of element, does not touch attributes.
`srTT` replaces the whole body of tags.
==============================================================================
FILETYPE RECIPES *sandwich-filetype-recipes*
Sandwich.vim has filetype specific settings. They will be available when
'filetype' option was set to a certain value. User settings are not
overwrittern by them, use only the recipes helpful for you. These recipes are
written in ftplugin/{filetype}/sandwich.vim.
If you don't want vim to load these files, set
`g:sandwich_no_{filetype}_ftplugin` as true in advance. For example, add the
following line to your vimrc in case you don't need tex specific recipes.
>
let g:sandwich_no_tex_ftplugin = 1
<
------------------------------------------------------------------------------
plaintex~
tex~
>
Surroundings Input
“{text}” u"
„{text}“ U"
ug
u,
«{text}» u<
uf
`{text}' l'
l`
``{text}'' l"
"`{text}"' L"
,,{text}`` l,
<<{text}>> l<
\{{text}\} \{
\[{text}\] \[
\left({text}\right) m(
\left[{text}\right] m[
\left|{text}\right| m|
\left\{{text}\right\} m{
\left\langle {text}\right\rangle m<
< The surroundings its input starting from 'm' could be removed/replaced
by a input `ma`, for example press `sdma`.
>
\big({text}\big) M(
\big[{text}\big] M[
\big|{text}\big| M|
\big\{{text}\big\} M{
\big\langle {text}\big\rangle M<
\begingroup{text}\endgroup gr
\gr
\toprule{text}\bottomrule tr
br
\tr
\br
\{input}{{text}} c
< This recipe asks user to input a string and then {input} is
substituted by the input string.
>
\begin{{input}}{text}\end{{input}} e
< This recipe asks user to input a string and then {input} is
substituted by the input string.
Use <Tab> to complete {input}, the completion items are loaded from
`g:sandwich#filetype#tex#environments`
(or `b:sandwich#filetype#tex#environments` if exists).
==============================================================================
FUNCTIONS *sandwich-functions*
sandwich#util#addlocal({recipes}) *sandwich#util#addlocal()*
This function appends the list of recipes {recipes} as buffer-local
settings with inheritance of the global settings. This is useful when
one wants to add filetype specific settings with keeping global
setting |g:sandwich#recipes| clean. Note that {recipe} is a |List| of
recipes.
>
autocmd FileType python call sandwich#util#addlocal([
\ {'buns': ['"""', '"""'], 'nesting': 0, 'input': ['3"']},
\ ])
<
==============================================================================
MISCELLANEOUS *sandwich-miscellaneous*
Introduce vim-surround keymappings~
If you want to use with vim-surround (vim script #1697) keymappings,
add the following line to your vimrc.
>
runtime macros/sandwich/keymap/surround.vim
<
NOTE: Unlike surround.vim, the inputs `(` and `)` behave as same.
If you want the spaces inside braces with `(` input, add the
lines.
>
runtime macros/sandwich/keymap/surround.vim
let g:sandwich#recipes += [
\ {'buns': ['{ ', ' }'], 'nesting': 1, 'match_syntax': 1,
\ 'kind': ['add', 'replace'], 'action': ['add'], 'input': ['{']},
\
\ {'buns': ['[ ', ' ]'], 'nesting': 1, 'match_syntax': 1,
\ 'kind': ['add', 'replace'], 'action': ['add'], 'input': ['[']},
\
\ {'buns': ['( ', ' )'], 'nesting': 1, 'match_syntax': 1,
\ 'kind': ['add', 'replace'], 'action': ['add'], 'input': ['(']},
\
\ {'buns': ['{\s*', '\s*}'], 'nesting': 1, 'regex': 1,
\ 'match_syntax': 1, 'kind': ['delete', 'replace', 'textobj'],
\ 'action': ['delete'], 'input': ['{']},
\
\ {'buns': ['\[\s*', '\s*\]'], 'nesting': 1, 'regex': 1,
\ 'match_syntax': 1, 'kind': ['delete', 'replace', 'textobj'],
\ 'action': ['delete'], 'input': ['[']},
\
\ {'buns': ['(\s*', '\s*)'], 'nesting': 1, 'regex': 1,
\ 'match_syntax': 1, 'kind': ['delete', 'replace', 'textobj'],
\ 'action': ['delete'], 'input': ['(']},
\ ]
<
`ys`, `yss`, `yS`, `ds`, `cs` in normal mode and `S` in visual mode
are available. Not in vim-surround but `dss` and `css` are also
available, these are similar as `ds` and `cs` but determine
deleted/replaced texts automatically. See the file directly for
detail.
Additionally, vim-sandwich provides several textobjects. They would
also be helpful, give it a try!
* Textobjects to select a text surrounded by braket or same characters
user input.
|<Plug>(textobj-sandwich-query-i)|, |<Plug>(textobj-sandwich-query-a)|
>
xmap is <Plug>(textobj-sandwich-query-i)
xmap as <Plug>(textobj-sandwich-query-a)
omap is <Plug>(textobj-sandwich-query-i)
omap as <Plug>(textobj-sandwich-query-a)
<
* Textobjects to select the nearest surrounded text automatically.
|<Plug>(textobj-sandwich-auto-i)|, |<Plug>(textobj-sandwich-auto-a)|.
>
xmap iss <Plug>(textobj-sandwich-auto-i)
xmap ass <Plug>(textobj-sandwich-auto-a)
omap iss <Plug>(textobj-sandwich-auto-i)
omap ass <Plug>(textobj-sandwich-auto-a)
<
* Textobjects to select a text surrounded by same characters user
input.
|<Plug>(textobj-sandwich-literal-query-i)|,
|<Plug>(textobj-sandwich-literal-query-a)|
>
xmap im <Plug>(textobj-sandwich-literal-query-i)
xmap am <Plug>(textobj-sandwich-literal-query-a)
omap im <Plug>(textobj-sandwich-literal-query-i)
omap am <Plug>(textobj-sandwich-literal-query-a)
<
------------------------------------------------------------------------------
Customize the behavior of magicchar-f~
`magicchar-f` can delete simple function-call like syntax:
>
func(arg) -- sdf --> arg
<
If you want to delete more advanced patterns, for example:
>
obj.method(arg) -- sdf --> arg
<
You can use `g:sandwich#magicchar#f#patterns` or
`b:sandwich_magicchar_f_patterns` for the purpose. Each of those are a list of
patterns like:
>
let g:sandwich#magicchar#f#patterns = [
\ {
\ 'header' : '\<\h\k*',
\ 'bra' : '(',
\ 'ket' : ')',
\ 'footer' : '',
\ },
\ ]
<
Those four values are all regex patterns, which match with something before
open parenthesis, open & close parentheses, something after close parenthesis.
Therefore, you can delete a method with an object by the following setting.
>
let g:sandwich#magicchar#f#patterns = [
\ {
\ 'header' : '\<\%(\h\k*\.\)*\h\k*',
\ 'bra' : '(',
\ 'ket' : ')',
\ 'footer' : '',
\ },
\ ]
<
`b:sandwich_magicchar_f_patterns` can be used to define filetype specific
setting.
>
augroup sandwich-ft-python
autocmd Filetype python let b:sandwich_magicchar_f_patterns = [
\ {
\ 'header' : '\<\%(\h\k*\.\)*\h\k*',
\ 'bra' : '(',
\ 'ket' : ')',
\ 'footer' : '',
\ },
\ ]
augroup END
<
The default settings is in `g:sandwich#magicchar#f#default_patterns`.
------------------------------------------------------------------------------
Any way to make a recipe deletes kinds of parentheses and brackets?~
See |sandwich-compound-recipes|.
==============================================================================
vim:tw=78:ts=8:ft=help:norl:noet:

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff