Commit d55c100e authored by Murukesh Mohanan's avatar Murukesh Mohanan

added new manpage settings based on http://unix.stackexchange.com/a/271905/70524

parent f22a24b0
*eregex.jax*
ファイル: eregex.vim, eregex_e.vim
作者: AKUTSU toshiyuki <locrian@mbd.ocn.ne.jp>
バージョン: 2.56
必要なもの: Vim version 6.1 かそれ以降。
説明: eregex.vim は、拡張正規表現を Vim の正規表現に変換します。
eregex_e.vim は、eregex.vim のコマンドを評価します。
1. 使用許諾 |eregex-license-to-use|
2. インストール |eregex-installations|
3. 関数 |eregex-functions|
4. コマンド |eregex-commands|
5. 使い方 |eregex-examples|
6. キーマップ |eregex-keymappings|
7. 原則 |eregex-principle|
8. 内部的な変換を表す一覧 |eregex-table|
9. 特殊なオプションとアトム |eregex-options|
10. マルチライン |eregex-multiline|
11. デリミタの制限 |eregex-limitation-of-delimiter|
12. Vim の正規表現について |eregex-about-vimregex|
==============================================================================
1. 使用許諾 *eregex-license-to-use*
eregex.vim と eregex_e.vim の著作権は、作者である AKUTSU toshiyuki に
帰属します。しかし、改変、再配布は自由にしてかまいません。
# GPL とか分かんないのだ。(^^ )>>
作者は本スクリプト(eregex.vim, eregex_e.vim) を使用したことによって生じた
いかなる損害について、一切の責任を負いません。
==============================================================================
2. インストール *eregex-installations*
参考 |add-plugin|
(1) UNIX/Linux
$HOME/.vim/plugin/eregex.vim
$HOME/.vim/plugin/eregex_e.vim
$HOME/.vim/doc/eregex_j.txt
それから、次のようにして helptags の再構築をします。
:helptags ~/.vim/doc
これで、:h :E2v とかできます。
(2) MS-Windows
eregex_j.txt は EUC-JP です。
MS-Windows の場合は予め ShiftJIS にしておいてください。
%HOME%\vimfiles\plugin\eregex.vim
%HOME%\vimfiles\plugin\eregex_e.vim
%HOME%\vimfiles\doc\eregex_j.txt
または、
%VIM%\vimfiles\plugin\eregex.vim
%VIM%\vimfiles\plugin\eregex_e.vim
%VIM%\vimfiles\doc\eregex_j.vim
それから、次のようにして helptags の再構築をします。
:helptags $HOME\vimfiles\doc
または、
:helptags $VIM\vimfiles\doc
これで、:h :E2v とかできます。
==============================================================================
3. 関数 *eregex-functions* *eregex*
*E2v()*
E2v({extendedregex} [, {iISCDMm}])
返り値は Vim の正規表現です。
>
:let vimregex = E2v('(?<=abc),\d+,(?=xzy)','i')
:echo vimregex
\c\%(abc\)\@<=,\d\+,\%(xzy\)\@=
<
オプションの詳しい説明は |eregex-options| や |eregex-multiline|
を見てください。
E2v("","V")
返り値は eregex.vim のバージョンです。
>
:echo E2v('','V')
248
<
E2v({replacement}, {R1,R2,R3})
これは、:S/pattern/to/ の "to" の部分で使う文字列を返します。
>
E2v('\r,\n,\&,&,\~,~', 'R1') => \n,\r,\&,&,\~,~
E2v('\r,\n,\&,&,\~,~', 'R2') => \r,\n,&,\&,~,\~
E2v('\r,\n,\&,&,\~,~', 'R3') => \n,\r,&,\&,~,\~
<
==============================================================================
4. コマンド *eregex-commands*
*:E2v*
:[range]E2v [iISCDMm]
Extended regex To Vim regex.
Replace each extended-regex in [range] with vim-style-regex.
*:M*
:M/eregex[/{offset} [iISCDMm]]
Match
:M/<span class="foo">.*?<\/span>/Im
==> /\C<span class="foo">\_.\{-}<\/span>
*:S*
:[range]S/{eregex}/{string}/[&cegpriISCDMm]
Substitute
:'<,'>S/(\d{1,3})(?=(\d\d\d)+($|\D))/\1,/g
==> :'<,'>s/\(\d\{1,3}\)\%(\(\d\d\d\)\+\($\|\D\)\)\@=/\1,/g
*:G* *:G!*
:[range]G/{eregex}/{command}
:[range]G!/{eregex}/{command}
Global
:G/<<-(["'])?EOD\1/,/^\s*EOD\>/:left 8
==> :g/<<-\(["']\)\=EOD\1/,/^\s*EOD\>/:left 8
*:V*
:[range]V/{eregex}/{command}
Vglobal
==============================================================================
5. 使い方 *eregex-examples*
(1) :E2v コマンド
次の拡張正規表現の行にカーソルを置く。
(\d{1,3})(?=(\d\d\d)+($|\D))
んで、:E2v を実行すると、次のようになる。
\(\d\{1,3}\)\%(\(\d\d\d\)\+\($\|\D\)\)\@=
(2) :M コマンド
>
:M/<Items\s+attr="media">.+?<\/Items>/Im
<
:normal! /\C<Items[ \t\r\n^L]\+attr="media">\_.\{-1,}<\/Items>
<Items attr="media">
<item name="cdrom" price="90" />
<item name="cdrw" price="500" />
<item name="dvd" price="1000" />
</Items>
(3) :S コマンド
>
:'<,'>S/(\d{1,3})(?=(\d\d\d)+($|\D))/\1,/g
<
:'<,'>s/\(\d\{1,3}\)\%(\(\d\d\d\)\+\($\|\D\)\)\@=/\1,/g
1 --> 1
12 --> 12
123 --> 123
1234 --> 1,234
12345 --> 12,345
123456 --> 123,456
1234567 --> 1,234,567
12345678 --> 12,345,678
123456789 --> 123,456,789
(4) :G コマンド
>
:G/^begin$/+1;/^end$/-1:S/\l+/\U&/g
<
:g/^begin$/+1;/^end$/-1:s/\l\+/\U&/g
begin
hello world.
hello world wide web.
hello The Internet.
end
|begin
| HELLO WORLD.
| HELLO WORLD WIDE WEB.
| HELLO THE INTERNET.
|end
(5) :V コマンド
説明省略。
==============================================================================
6. キーマップ *eregex-keymappings*
/ で行なう通常の検索と :M/ を入れ替える。
.vimrc に以下を書く。 ( MS-Windows の場合 _vimrc か _gvimrc )
nnoremap / :M/
nnoremap ,/ /
"/" で、:M/ になり、",/" で従来の "/" が使えます。
--------------------
~/.vimrc の中に、
let eregex_replacement=3
を書いておくと :S コマンドの動作が次のように変わります。
:S/pattern/\r,\n,\&,&,\~,~/
:s/pattern/\n,\r,&,\&,~,\~/
+--------------------+-----------------------------+
| eregex_replacement | :S/pattern/\n,\r,&,\&,~,\~/ |
+--------------------+-----------------------------+
| 0 | :s/pattern/\n,\r,&,\&,~,\~/ |
| 1 | :s/pattern/\r,\n,&,\&,~,\~/ |
| 2 | :s/pattern/\n,\r,\&,&,\~,~/ |
| 3 | :s/pattern/\r,\n,\&,&,\~,~/ |
+--------------------+-----------------------------+
==============================================================================
7. 原則 *eregex-principle*
eregex.vim において、
「選択」「繰り返し」「丸カッコ」は、拡張正規表現流 を採用する。
それ以外は Vim の正規表現に従う。
==============================================================================
8. 内部的な変換を表す一覧 *eregex-table*
左には拡張正規表現を書き、右には Vim 流正規表現('magic')を書く。
選択
--------------------
:M/a|b /a\|b
繰り返し
--------------------
:M/a* /a*
:M/a+ /a\+
:M/a? /a\=
:M/a*? /a\{-}
:M/a+? /a\{-1,}
:M/a?? /a\{-,1}
:M/a{3,5} /a\{3,5}
:M/a{3,} /a\{3,}
:M/a{,5} /a\{,5}
:M/a{3,5}? /a\{-3,5}
:M/a{3,}? /a\{-3,}
:M/a{,5}? /a\{-,5}
丸カッコ(パレン)
--------------------
:M/(abc) /\(abc\)
:M/(?:abc) /\%(abc\)
:M/(?<=abc) /\%(abc\)\@<=
:M/(?<!abc) /\%(abc\)\@<!
:M/(?=abc) /\%(abc\)\@=
:M/(?!abc) /\%(abc\)\@!
:M/(?>abc) /\%(abc\)\@>
文字そのもの
--------------------
:M/\\,\|,\(,\),\{,\},\?,\+,\*,\[,\] /\\,|,(,),{,},?,+,\*,\[,\]
:M/\^,\$ /\^,\$
拡張正規表現で使えないもの
--------------------
\A, \b, \B, \G, \Z, \z
これらは全て Vim のものとして扱われる。
(?i:a) や (?-i) なども使えない。
Vim の正規表現で使えないもの
--------------------
\%(re\) 等、パレン(丸カッコ) を使うもの全般。
~ matches the last given substitute string
\m 'magic' on for the following chars in the pattern
\M 'magic' off for the following chars in the pattern
\v the following chars in the pattern are "very magic"
\V the following chars in the pattern are "very nomagic"
\x hex digit: [0-9A-Fa-f]
\\x[0-9A-Fa-f]{1,2} の場合、文字そのものに変換する。
\x82\xa0 => 'あ' ( shift-jis, cp932 )
ただし、0x00 と 0x0a と 0x08 は変換しません。
Vim の正規表現で使えるもの
--------------------
大抵使えます。(^^;)
\d, \D, \w, \W, \s, \S, \a, \A, \u, \U, \b, ...
\<, \>, \zs, \ze
\_[a-z], \%[abc], [[:alpha:]], \_., \_^, \_$
\%23l, \%23c, \%23v, \%#
など。
==============================================================================
9. 特殊なオプションとアトム *eregex-options*
Note: "^L" は \x0c
eregex.vim Vim
---------------------------------------
:M/a/i /\ca/
:M/\ca/ /\ca/
:M/a/I /\Ca/
:M/\Ca/ /\Ca/
:M/\s/S /[ \t\r\n^L]
:M/\S/S /[^ \t\r^L]
:M/[^az]/C /\_[^az]/
:M/\W/C /\_W/
:M/./D /\_./
:M/\s[^az]./M /[ \t\r\n^L]\_[^az]./
:M/\s[^az].\M/ 同上。
:M/\s[^az]./m /[ \t\r\n^L]\_[^az]\_./
:M/\s[^az].\m/ 同上。
+--------+------+--------------------------------------------------------+
| OPTION | ATOM | 説明 |
+--------+------+--------------------------------------------------------+
| /i | \c | 大小文字の区別無し。 |
| /I | \C | 大小文字の区別あり。 |
+--------+------+--------------------------------------------------------+
| /S | | \s および \S を [ \t\r\n^L] や [^ \t\r^L] に変換する。 |
| /C | | 補集合が改行にもマッチする。 |
| /D | | ドットが改行にもマッチする。 |
+--------+------+--------------------------------------------------------+
| /M | \M | /S と /C を行なう。 部分マルチライン。 |
| /m | \m | /S と /C と /D を行なう。完全マルチライン。 |
+--------+------+--------------------------------------------------------+
Note:
(A) オプション /iImM
(B) \c, \C, \m, \M
(C) (?i), (?I), (?m), (?M)
これらが同時に指定された場合、上の方が優先順位が高い。
ちなみに、(?M) と (?m) は、ブラケットの中の \s には適用されません。
==============================================================================
10. マルチライン *eregex-multiline*
とりあえず以下の表を見て。(^^;)
+-----+----------------------------------------------+--------------------+
| Num | eregex.vim => vim regex | ruby regex |
+-----+----------------------------------------------+--------------------+
| (1) | :M/a\s[^az].z/ => /a\s[^az].z/ | /a[ \t][^az\n].z/ |
+-----+----------------------------------------------+--------------------+
| | :M/a\s[^az].z/S => /a[ \t\r\n^L][^az].z/ | /a\s[^az\n].z/ |
| | :M/a\s[^az].z/C => /a\s\_[^az].z/ | /a[ \t][^az].z/ |
| | :M/a\s[^az].z/D => /a\s[^az]\_.z/ | /a[ \t][^az\n].z/m |
+-----+----------------------------------------------+--------------------+
| (2) | :M/a\s[^az].z/M => /a[ \t\r\n^L]\_[^az].z/ | /a\s[^az].z/ |
| (3) | :M/a\s[^az].z/m => /a[ \t\r\n^L]\_[^az]\_.z/ | /a\s[^az].z/m |
+-----+----------------------------------------------+--------------------+
(1) は、「文字クラス」が Vim 流。
(2) は、「文字クラス」が Ruby 流。
Vim 流に言えば、改行にマッチする所が増えたので、部分マルチライン。
Ruby 流に言えば、マルチラインでない。よってオプションは大文字の M 。
(3) は、いわゆる Ruby 流のマルチライン。
Note:
Vim の正規表現では、/[^az]/ は改行にマッチしません。
改行にマッチしないことを明示して /[^az\n]/ と書く必要はありません。
/[^az\n]/ は意図に反して改行にもマッチします。
よって、本来 /[^ \t\r\n^L]/ とするべきところを、/[^ \t\r^L]/ に
変換している場合があります。
原則的に Vim では、[^...] の中に \n を書いてはいけません。
==============================================================================
11. デリミタの制限 *eregex-limitation-of-delimiter*
:M で使える区切り文字は / と ? だけです。
:S 、:G および :V で使える区切り文字は /, #, @ です。
これらの使用方法は :s 、:g 、:v と同じです。
制限も同様です。
区切り文字を @ にするといろいろ制限があります。
一見うまくいきそうに見えてダメな例。
"foo@bar.baz.co.jp" を "foo@hoge.co.jp" に置換しようとして、
>
:%s@\<foo\@bar\.baz\.co\.jp\>@foo\@hoge.co.jp@Ig
<
は、エラーです。
Vim の正規表現で、\@ は特別な扱いを受けています。
==============================================================================
12. Vim の正規表現について *eregex-about-vimregex*
以下 カーソルを "111,222,333" の行に置いて、:S... を実行してください。
(1)通常のサブマッチ。
111,222,333
>
:S/(\d+),(\d+),(\d+)/\=submatch(1) + submatch(2) + submatch(3)
<
666
(2)Vim 独自機能。
マッチデータ($&, &, matchdata) と、サブマッチを分離できます。
\zs と \ze を使う。 See :h /\zs
111,222,333
>
:S/(\d+),\zs\d+\ze,(\d+)/\=submatch(1) + submatch(0) + submatch(2)
<
111,666,333
(3)
以下の方が分かりやすいかも。
111,222,333
>
:S/(\d+),\zs(\d+)\ze,(\d+)/\=submatch(1) + submatch(2) + submatch(3)
<
111,666,333
\zs と \ze を使うと、マッチデータに含まれないサブマッチを操作できます。
(4) \_x の機能。
\u で [A-Z] を表す。
\_u で [A-Z\n] を表す。
\_[A-Z] は [A-Z\n] と同じ。
大文字以外で改行を含む文字。
\_U == \_[^A-Z]
\_. は改行を含む任意の文字。
(5) ^ と \_^ および $ と \_$ の違い。
$ を例にとります。
通常 $ は
(1)正規表現の一番最後。
(2) ) の直前。
(3) | の直前。
にある場合だけ行末を表す。
ところが任意の場所で行末を表せるのが \_$ 。
111,222,333
>
:S/(\d+),(\d+),(\d+)\zs\_$\ze/\=',' . (submatch(1) + submatch(2) + submatch(3))
<
111,222,333,666
ここで使っている \_$ の代わりに $ を使っても意図した結果になりません。
Note:
\_^ と \_$ は perl の /m オプションとは全然違います。
==============================================================================
13. 履歴
revision 2.55
(1) E2v() にバージョン番号や、sub-replace-special の置換を加えた。
(2) \v を 0x0b に置換するようにした。
(3) :M/pattern/ でマッチしなくても、@/ を更新した。
revision 2.35
(1) オプション S,C,D,M,m の追加と変更。
revision 1.4x
(1) :S/\x2f/\\/g とかすると、:s///\\/g に変換してしまうバグ修正。
(2) エスケープされたデリミタを検索履歴ではアンエスケープした。
デリミタが '@' の場合を除く。
(3) オプション m の修正。
revision 1.13
:G で ! を使えるようにした。
revision 1.1.1.21
:S の /c オプションで確認のプロンプトが見えなくなってしまう問題修正。
-- vim:ft=help:
*eregex.txt*
File: eregex.vim, eregex_e.vim
Author: AKUTSU toshiyuki <locrian@mbd.ocn.ne.jp>
Maintainer: othree <othree@gmail.com>
Version: 2.56
Required: Vim version 6.1
Note: eregex.vim is used to convert regexp notation style.
eregex_e.vim is used to map command for eregex.vim.
1. License |eregex-license-to-use|
2. Installation |eregex-installations|
3. Functions |eregex-functions|
4. Command |eregex-commands|
5. Usage |eregex-examples|
6. Keymap |eregex-keymappings|
7. Principle |eregex-principle|
8. Convert Table |eregex-table|
9. Options |eregex-options|
10. Multiline |eregex-multiline|
11. Limitation of Delimiter |eregex-limitation-of-delimiter|
12. About Vim Regexp |eregex-about-vimregex|
==============================================================================
1. License *eregex-license-to-use*
Copyright of eregex.vim and eregex_e.vim belongs to AKUTSU toshiyuki.
It is free to change and redistribute this script. You can think as an
GPL License software.
Author will not take any responsibility for damages due to using this
script (eregex.vim, eregex_e.vim).
==============================================================================
2. Installation *eregex-installations*
Open eregex.vba using Vim. And execute the following command.
>
:so %
<
==============================================================================
3. Functions *eregex-functions* *eregex*
*E2v()*
E2v({extendedregex} [, {iISCDMm}])
Vim regexp notation will return.
>
:let vimregex = E2v('(?<=abc),\d+,(?=xzy)','i')
:echo vimregex
<
Detail of option value can be found at |eregex-options|
or |eregex-multiline|
E2v("","V")
Return eregex.vim version number
>
:echo E2v('','V')
248
<
E2v({replacement}, {R1,R2,R3})
Return the "to" part of :S/pattern/to/ .
>
E2v('\r,\n,\&,&,\~,~', 'R1') => \n,\r,\&,&,\~,~
E2v('\r,\n,\&,&,\~,~', 'R2') => \r,\n,&,\&,~,\~
E2v('\r,\n,\&,&,\~,~', 'R3') => \n,\r,&,\&,~,\~
<
==============================================================================
4. Command *eregex-commands*
*:E2v*
:[range]E2v [iISCDMm]
Extended regex To Vim regex.
Replace each extended-regex in [range] with vim-style-regex.
*:M*
:M/eregex[/{offset} [iISCDMm]]
Match
:M/<span class="foo">.*?<\/span>/Im
==> /\C<span class="foo">\_.\{-}<\/span>
*:S*
:[range]S/{eregex}/{string}/[&cegpriISCDMm]
Substitute
:'<,'>S/(\d{1,3})(?=(\d\d\d)+($|\D))/\1,/g
==> :'<,'>s/\(\d\{1,3}\)\%(\(\d\d\d\)\+\($\|\D\)\)\@=/\1,/g
*:G* *:G!*
:[range]G/{eregex}/{command}
:[range]G!/{eregex}/{command}
Global
:G/<<-(["'])?EOD\1/,/^\s*EOD\>/:left 8
==> :g/<<-\(["']\)\=EOD\1/,/^\s*EOD\>/:left 8
*:V*
:[range]V/{eregex}/{command}
Vglobal
==============================================================================
5. Usage *eregex-examples*
(1) :E2v command
Change the regexp notation style of the cursor line.
(\d{1,3})(?=(\d\d\d)+($|\D))
Move cursor to this line and execute :E2v command will change this line to
the following result.
\(\d\{1,3}\)\%(\(\d\d\d\)\+\($\|\D\)\)\@=
(2) :M command
>
:M/<Items\s+attr="media">.+?<\/Items>/Im
<
:normal! /\C<Items[ \t\r\n^L]\+attr="media">\_.\{-1,}<\/Items>
<Items attr="media">
<item name="cdrom" price="90" />
<item name="cdrw" price="500" />
<item name="dvd" price="1000" />
</Items>
(3) :S command
>
:'<,'>S/(\d{1,3})(?=(\d\d\d)+($|\D))/\1,/g
<
:'<,'>s/\(\d\{1,3}\)\%(\(\d\d\d\)\+\($\|\D\)\)\@=/\1,/g
1 --> 1
12 --> 12
123 --> 123
1234 --> 1,234
12345 --> 12,345
123456 --> 123,456
1234567 --> 1,234,567
12345678 --> 12,345,678
123456789 --> 123,456,789
(4) :G command
>
:G/^begin$/+1;/^end$/-1:S/\l+/\U&/g
<
:g/^begin$/+1;/^end$/-1:s/\l\+/\U&/g
begin
hello world.
hello world wide web.
hello The Internet.
end
|begin
| HELLO WORLD.
| HELLO WORLD WIDE WEB.
| HELLO THE INTERNET.
|end
(5) :V command
Skipped.
==============================================================================
6. keymap *eregex-keymappings*
You can add the following keymap to use / instead of type :/M
nnoremap / :M/
nnoremap ? :M?
nnoremap ,/ /
nnoremap ,? /
"/" will use :M/ to search. ",/" will use the original "/".
--------------------
Add the following line to ~/.vimrc
let eregex_replacement=3
will make :S have the following rules.
:S/pattern/\r,\n,\&,&,\~,~/
:s/pattern/\n,\r,&,\&,~,\~/
+--------------------+-----------------------------+
| eregex_replacement | :S/pattern/\n,\r,&,\&,~,\~/ |
+--------------------+-----------------------------+
| 0 | :s/pattern/\n,\r,&,\&,~,\~/ |
| 1 | :s/pattern/\r,\n,&,\&,~,\~/ |
| 2 | :s/pattern/\n,\r,\&,&,\~,~/ |
| 3 | :s/pattern/\r,\n,\&,&,\~,~/ |
+--------------------+-----------------------------+
==============================================================================
7. Principle *eregex-principle*
eregex.vim adopts the way of extended regex about "alternation",
"repetition" and "grouping".
==============================================================================
8. Convert Table *eregex-table*
Perl style on left side. Vim style ('magic') on right side.
Alternation
--------------------
:M/a|b /a\|b
Repetition
--------------------
:M/a* /a*
:M/a+ /a\+
:M/a? /a\=
:M/a*? /a\{-}
:M/a+? /a\{-1,}
:M/a?? /a\{-,1}
:M/a{3,5} /a\{3,5}
:M/a{3,} /a\{3,}
:M/a{,5} /a\{,5}
:M/a{3,5}? /a\{-3,5}
:M/a{3,}? /a\{-3,}
:M/a{,5}? /a\{-,5}
Grouping
--------------------
:M/(abc) /\(abc\)
:M/(?:abc) /\%(abc\)
:M/(?<=abc) /\%(abc\)\@<=
:M/(?<!abc) /\%(abc\)\@<!
:M/(?=abc) /\%(abc\)\@=
:M/(?!abc) /\%(abc\)\@!
:M/(?>abc) /\%(abc\)\@>
Special Characters
--------------------
:M/\\,\|,\(,\),\{,\},\?,\+,\*,\[,\] /\\,|,(,),{,},?,+,\*,\[,\]
:M/\^,\$ /\^,\$
Not support
--------------------
\A, \b, \B, \G, \Z, \z
Vim doesn't support these features.
(?i:a) and (?-i) neither.
Unusable Vim regexp notation
--------------------
\%(re\) and square rackets
~ matches the last given substitute string
\m 'magic' on for the following chars in the pattern
\M 'magic' off for the following chars in the pattern
\v the following chars in the pattern are "very magic"
\V the following chars in the pattern are "very nomagic"
\x hex digit: [0-9A-Fa-f]
\\x[0-9A-Fa-f]{1,2} will change to character.
\x82\xa0 => '' ( shift-jis, cp932 )
But 0x00 and 0x0a and 0x08 will not change.
Usable Vim regexp notations
--------------------
\d, \D, \w, \W, \s, \S, \a, \A, \u, \U, \b, ...
\<, \>, \zs, \ze
\_[a-z], \%[abc], [[:alpha:]], \_., \_^, \_$
\%23l, \%23c, \%23v, \%#
==============================================================================
9. Special Option and Atom *eregex-options*
Note: "^L" is \x0c
eregex.vim Vim
---------------------------------------
:M/a/i /\ca/
:M/\ca/ /\ca/
:M/a/I /\Ca/
:M/\Ca/ /\Ca/
:M/\s/S /[ \t\r\n^L]
:M/\S/S /[^ \t\r^L]
:M/[^az]/C /\_[^az]/
:M/\W/C /\_W/
:M/./D /\_./
:M/\s[^az]./M /[ \t\r\n^L]\_[^az]./
:M/\s[^az].\M/ Same as above.
:M/\s[^az]./m /[ \t\r\n^L]\_[^az]\_./
:M/\s[^az].\m/ Same as above.
+--------+------+--------------------------------------------------------+
| OPTION | ATOM | NOTE |
+--------+------+--------------------------------------------------------+
| /i | \c | Case insensitive |
| /I | \C | Case sensitive |
+--------+------+--------------------------------------------------------+
| /S | | \s and \S becomes [ \t\r\n^L] and [^ \t\r^L] |
| /C | | [] brackets will also match line break. |
| /D | | Dot will match line break |
+--------+------+--------------------------------------------------------+
| /M | \M | Use /S and /C . Partial multiline support |
| /m | \m | Use /S, /C and /D . All support multiline |
+--------+------+--------------------------------------------------------+
Note:
(A) Option /iImM
(B) \c, \C, \m, \M
(C) (?i), (?I), (?m), (?M)
If you use these at the same time. The priority will follow the order.
If you use (?M) and (?m), \s in bracket will not work.
==============================================================================
10. Multiline *eregex-multiline*
+-----+----------------------------------------------+--------------------+
| Num | eregex.vim => vim regex | ruby regex |
+-----+----------------------------------------------+--------------------+
| (1) | :M/a\s[^az].z/ => /a\s[^az].z/ | /a[ \t][^az\n].z/ |
+-----+----------------------------------------------+--------------------+
| | :M/a\s[^az].z/S => /a[ \t\r\n^L][^az].z/ | /a\s[^az\n].z/ |
| | :M/a\s[^az].z/C => /a\s\_[^az].z/ | /a[ \t][^az].z/ |
| | :M/a\s[^az].z/D => /a\s[^az]\_.z/ | /a[ \t][^az\n].z/m |
+-----+----------------------------------------------+--------------------+
| (2) | :M/a\s[^az].z/M => /a[ \t\r\n^L]\_[^az].z/ | /a\s[^az].z/ |
| (3) | :M/a\s[^az].z/m => /a[ \t\r\n^L]\_[^az]\_.z/ | /a\s[^az].z/m |
+-----+----------------------------------------------+--------------------+
(1) is Vim style character class.
(2) is Ruby style character class.
(3) is Ruby style multiline.
Note:
In Vim style regexp, /[^az]/ will not match break line.
But it is incorrect to to write /[^az\n]/ to point this out.
/[^az\n]/ will match breakline.
So we might use /[^ \t\r^L]/ instead of /[^ \t\r\n^L]/ .
Just remember not write \n in [^...] .
==============================================================================
11. Limitation of Delimiter *eregex-limitation-of-delimiter*
:M only support / and ? .
:S, :G and :V supports /, #, @ .
Usage and limitation are the same as :s, :g and :v
Delimiter use @ will have some more limitation.
For example:
To replace "foo@bar.baz.co.jp" with "foo@hoge.co.jp"
>
:%s@\<foo\@bar\.baz\.co\.jp\>@foo\@hoge.co.jp@Ig
<
Will fail.
\@ have special meaning in Vim regular expression .
==============================================================================
12. About Vim Regular Expression *eregex-about-vimregex*
The following samples are all in a line with content "111,222,333".
And use :S to execute replace.
(1)Regular submatch
111,222,333
>
:S/(\d+),(\d+),(\d+)/\=submatch(1) + submatch(2) + submatch(3)
<
666
(2)Vim special feature
Match data($&, &, matchdata) and submatch can be seperated.
Use \zs and \ze . See :h /\zs for more information.
111,222,333
>
:S/(\d+),\zs\d+\ze,(\d+)/\=submatch(1) + submatch(0) + submatch(2)
<
111,666,333
(3)
One more example
111,222,333
>
:S/(\d+),\zs(\d+)\ze,(\d+)/\=submatch(1) + submatch(2) + submatch(3)
<
111,666,333
Use \zs and \ze to control matchdata and submatch.
(4) \_x
\u is [A-Z]
\_u is [A-Z\n]
\_[A-Z] is [A-Z\n]
Not uppercase characters and line break.
\_U == \_[^A-Z]
\_. is any character including line break.
(5) Difference between ^ and \_^ or $ and \_$
Take $ for example
$ is used in the following position
(1) The last of regexp.
(2) Just before ) .
(3) Just before | .
\_$ can be used anywhere to present as a line break.
111,222,333
>
:S/(\d+),(\d+),(\d+)\zs\_$\ze/\=',' . (submatch(1) + submatch(2) + submatch(3))
<
111,222,333,666
If use $ instead of \_$ in this example will have different result.
Note:
\_^ and \_$ is totally different from /m option in Perl regexp.
==============================================================================
13. Changes
revision 2.56
(1) Add support for "?"
-- vim:ft=help:
*haskellmode.txt* Haskell Mode Plugins 02/05/2009
Authors:
Claus Reinke <claus.reinke@talk21.com> ~
Homepage:
http://projects.haskell.org/haskellmode-vim
CONTENTS *haskellmode*
1. Overview |haskellmode-overview|
1.1 Runtime Requirements |haskellmode-requirements|
1.2 Quick Reference |haskellmode-quickref|
2. Settings |haskellmode-settings|
2.1 GHC and web browser |haskellmode-settings-main|
2.2 Fine tuning - more configuration options |haskellmode-settings-fine|
3. GHC Compiler Integration |haskellmode-compiler|
4. Haddock Integration |haskellmode-haddock|
4.1 Indexing |haskellmode-indexing|
4.2 Lookup |haskellmode-lookup|
4.3 Editing |haskellmode-editing|
5. Hpaste Integration |haskellmode-hpaste|
6. Additional Resources |haskellmode-resources|
==============================================================================
*haskellmode-overview*
1. Overview ~
The Haskell mode plugins provide advanced support for Haskell development
using GHC/GHCi on Windows and Unix-like systems. The functionality is
based on Haddock-generated library indices, on GHCi's interactive
commands, or on simply activating (some of) Vim's built-in program editing
support in Haskell-relevant fashion. These plugins live side-by-side with
the pre-defined |syntax-highlighting| support for |haskell| sources, and
any other Haskell-related plugins you might want to install (see
|haskellmode-resources|).
The Haskell mode plugins consist of three filetype plugins (haskell.vim,
haskell_doc.vim, haskell_hpaste.vim), which by Vim's |filetype| detection
mechanism will be auto-loaded whenever files with the extension '.hs' are
opened, and one compiler plugin (ghc.vim) which you will need to load from
your vimrc file (see |haskellmode-settings|).
*haskellmode-requirements*
1.1 Runtime Requirements ~
The plugins require a recent installation of GHC/GHCi. The functionality
derived from Haddock-generated library indices also requires a local
installation of the Haddock documentation for GHC's libraries (if there is
no documentation package for your system, you can download a tar-ball from
haskell.org), as well as an HTML browser (see |haddock_browser|). If you
want to use the experimental hpaste interface, you will also need Wget.
* GHC/GHCi ~
Provides core functionality. http://www.haskell.org/ghc
* HTML library documentation files and indices generated by Haddock ~
These usually come with your GHC installation, possibly as a separate
package. If you cannot get them this way, you can download a tar-ball
matching your GHC version from http://www.haskell.org/ghc/docs/
* HTML browser with basic CSS support ~
For browsing Haddock docs.
* Wget ~
For interfacing with http://hpaste.org.
Wget is widely available for modern Unix-like operating systems. Several
ports also exist for Windows, including:
- Official GNU Wget (natively compiled for Win32)
http://www.gnu.org/software/wget/#downloading
- UnxUtils Wget (natively compiled for Win32, bundled with other ported
Unix utilities)
http://sourceforge.net/projects/unxutils/
- Cygwin Wget (emulated POSIX in Win32, must be run under Cygwin)
http://cygwin.com/packages/wget/
*haskellmode-quickref*
1.2 Quick Reference ~
|:make| load into GHCi, show errors (|quickfix| |:copen|)
|_ct| create |tags| file
|_si| show info for id under cursor
|_t| show type for id under cursor
|_T| insert type declaration for id under cursor
|balloon| show type for id under mouse pointer
|_?| browse Haddock entry for id under cursor
|_?1| search Hoogle for id under cursor
|_?2| search Hayoo! for id under cursor
|:IDoc| {identifier} browse Haddock entry for unqualified {identifier}
|:MDoc| {module} browse Haddock entry for {module}
|:FlagReference| {s} browse Users Guide Flag Reference for section {s}
|_.| qualify unqualified id under cursor
|_i| add 'import <module>(<identifier>)' for id under cursor
|_im| add 'import <module>' for id under cursor
|_iq| add 'import qualified <module>(<identifier>)' for id under cursor
|_iqm| add 'import qualified <module>' for id under cursor
|_ie| make imports explit for import statement under cursor
|_opt| add OPTIONS_GHC pragma
|_lang| add LANGUAGE pragma
|i_CTRL-X_CTRL-O| insert-mode completion based on imported ids (|haskellmode-XO|)
|i_CTRL-X_CTRL-U| insert-mode completion based on documented ids (|haskellmode-XU|)
|i_CTRL-N| insert-mode completion based on imported sources
|:GHCi|{command/expr} run GHCi command/expr in current module
|:GHCStaticOptions| edit static GHC options for this buffer
|:DocSettings| show current Haddock-files-related plugin settings
|:DocIndex| populate Haddock index
|:ExportDocIndex| cache current Haddock index to a file
|:HpasteIndex| Read index of most recent entries from hpaste.org
|:HpastePostNew| Submit current buffer as a new hpaste
==============================================================================
*haskellmode-settings*
2. Settings ~
The plugins try to find their dependencies in standard locations, so if
you're lucky, you will only need to set |compiler| to ghc, and configure
the location of your favourite web browser. You will also want to make
sure that |filetype| detection and |syntax| highlighting are on. Given the
variety of things to guess, however, some dependencies might not be found
correctly, or the defaults might not be to your liking, in which case you
can do some more fine tuning. All of this configuration should happen in
your |vimrc|.
>
" enable syntax highlighting
syntax on
" enable filetype detection and plugin loading
filetype plugin on
<
*haskellmode-settings-main*
2.1 GHC and web browser ~
*compiler-ghc* *ghc-compiler*
To use the features provided by the GHC |compiler| plugin, use the
following |autocommand| in your vimrc:
>
au BufEnter *.hs compiler ghc
<
*g:ghc*
If the compiler plugin can't locate your GHC binary, or if you have
several versions of GHC installed and have a preference as to which binary
is used, set |g:ghc|:
>
:let g:ghc="/usr/bin/ghc-6.6.1"
<
*g:haddock_browser*
The preferred HTML browser for viewing Haddock documentation can be set as
follows:
>
:let g:haddock_browser="/usr/bin/firefox"
<
*haskellmode-settings-fine*
2.2 Fine tuning - more configuration options ~
Most of the fine tuning is likely to happen for the haskellmode_doc.vim
plugin, so you can check the current settings for this plugin via the
command |:DocSettings|. If all the settings reported there are to your
liking, you probably won't need to do any fine tuning.
*g:haddock_browser_callformat*
By default, the web browser|g:haddock_browser| will be started
asynchronously (in the background) on Windows or when vim is running in a
GUI, and synchronously (in the foreground) otherwise. These settings seem
to work fine if you are using a console mode browser (eg, when editing in
a remote session), or if you are starting a GUI browser that will launch
itself in the background. But if these settings do not work for you, you
can change the default browser launching behavior.
This is controlled by |g:haddock_browser_callformat|. It specifies a
format string which uses two '%s' parameters, the first representing the
path of the browser to launch, and the second is the documentation URL
(minus the protocol specifier, i.e. file://) passed to it by the Haddock
plugin. For instance, to launch a GUI browser on Unix-like systems and
force it to the background (see also |shellredir|):
>
:let g:haddock_browser_callformat = '%s file://%s '.printf(&shellredir,'/dev/null').' &'
<
*g:haddock_docdir*
Your system's installed Haddock documentation for GHC and its libraries
should be automatically detected. If the plugin can't locate them, you
must point |g:haddock_docdir| to the path containing the master index.html
file for the subdirectories 'libraries', 'Cabal', 'users_guide', etc.:
>
:let g:haddock_docdir="/usr/local/share/doc/ghc/html/"
<
*g:haddock_indexfiledir*
The information gathered from Haddock's index files will be stored in a
file called 'haddock_index.vim' in a directory derived from the Haddock
location, or in $HOME. To configure another directory for the index file,
use:
>
:let g:haddock_indexfiledir="~/.vim/"
<
*g:wget*
If you also want to try the experimental hpaste functionality, you might
you need to set |g:wget| before the |hpaste| plugin is loaded (unless wget
is in your PATH):
>
:let g:wget="C:\Program Files\wget\wget.exe"
<
Finally, the mappings actually use|<LocalLeader>|behind the scenes, so if
you have to, you can redefine|maplocalleader|to something other than '_'.
Just remember that the docs still refer to mappings starting with '_', to
avoid confusing the majority of users!-)
==============================================================================
*haskellmode-compiler* *ghc*
3. GHC Compiler Integration ~
The GHC |compiler| plugin sets the basic |errorformat| and |makeprg| to
enable |quickfix| mode using GHCi, and provides functionality for show
info (|_si|), show type (|_t| or mouse |balloon|), add type declaration
(|_T|), create tag file (|_ct|), and insert-mode completion
(|i_CTRL-X_CTRL-O|) based on GHCi browsing of the current and imported
modules.
To avoid frequent calls to GHCi, type information is cached in Vim. The
cache will be populated the first time a command depends on it, and will
be refreshed every time a |:make| goes through without generating errors
(if the |:make| does not succeed, the old types will remain available in
Vim). You can also unconditionally force reloading of type info using
|:GHCReload| (if GHCi cannot load your file, the type info will be empty).
In addition to the standard|quickfix| commands, the GHC compiler plugin
provides:
*:GHCReload*
:GHCReload Reload modules and unconditionally refresh cache of
type info. Usually, |:make| is prefered, as that will
refresh the cache only if GHCi reports no errors, and
show the errors otherwise.
*:GHCStaticOptions*
:GHCStaticOptions Edit the static GHC options (more generally, options
that cannot be set by in-file OPTIONS_GHC pragmas)
for the current buffer. Useful for adding hidden
packages (-package ghc), or additional import paths
(-isrc; you will then also want to augment |path|).
If you have static options you want to set as
defaults, you could use b:ghc_staticoptions, eg:
>
au FileType haskell let b:ghc_staticoptions = '-isrc'
au FileType haskell setlocal path += src
<
*:GHCi*
:GHCi {command/expr} Run GHCi commands/expressions in the current module.
*_ct*
_ct Create |tags| file for the current Haskell source
file. This uses GHCi's :ctags command, so it will work
recursively, but will only list tags for exported
entities.
*_opt*
_opt Shows a menu of frequently used GHC compiler options
(selecting an entry adds the option as a pragma to the
start of the file). Uses popup menu (GUI) or :emenu
and command-line completion (CLI).
*_lang*
_lang Shows a menu of the LANGUAGE options supported by GHC
(selecting an entry adds the language as a pragma to
the start of the file). Uses popup menu (GUI) or
:emenu and command-line completion (CLI).
*_si*
_si Show extended information for the name under the
cursor. Uses GHCi's :info command. Output appears in
|preview-window| (when done, close with |:pclose|).
*_t*
_t Show type for the name under the cursor. Uses cached
info from GHCi's :browse command.
*_T*
_T Insert type declaration for the name under the cursor.
Uses cached info from GHCi's :browse command.
*haskellmode-XO* *haskellmode-omni-completion*
CTRL-X CTRL-O Standard insert-mode omni-completion based on the
cached type info from GHCi browsing current and
imported modules. Only names from the current and from
imported modules are included (the completion menu
also show the type of each identifier).
==============================================================================
*haskellmode-haddock* *haddock*
4. Haddock Integration ~
Haskell mode integrates with Haddock-generated HTML documentation,
providing features such as navigating to the Haddock entry for the
identifier under the cursor (|_?|), completion for the identifier under
the cursor (|i_CTRL-X_CTRL-U|), and adding import statements (|_i| |_im|
|_iq| |_iqm|) or module qualifier (|_.|) for the identifier under the
cursor.
These commands operate on an internal Haddock index built from the
platform's installed Haddock documentation for GHC's libraries. Since
populating this index takes several seconds, it should be stored as a
file called 'haddock_index.vim' in the directory specified by
|g:haddock_indexfiledir|.
Some commands present a different interface (popup menu or command-line
completion) according to whether the current Vim instance is graphical or
console-based (actually: whether or not the GUI is running). Such
differences are marked below with the annotations (GUI) and (CLI),
respectively.
|:DocSettings| shows the settings for this plugin. If you are happy with
them, you can call |:ExportDocIndex| to populate and write out the
documentation index (should be called once for every new version of GHC).
*:DocSettings*
:DocSettings Show current Haddock-files-related plugin settings.
*haskellmode-indexing*
4.1 Indexing ~
*:DocIndex*
:DocIndex Populate the Haddock index from the GHC library
documentation.
*:ExportDocIndex*
:ExportDocIndex Cache the current Haddock index to a file (populate
index first, if empty).
*haskellmode-lookup*
4.2 Lookup ~
*_?*
_? Open the Haddock entry (in |haddock_browser|) for an
identifier under the cursor, selecting full
qualifications from a popup menu (GUI) or via
command-line completion (CLI), if the identifier is
not qualified.
*_?1*
_?1 Search Hoogle (using |haddock_browser|) for an
identifier under the cursor.
*_?2*
_?2 Search Hayoo! (using |haddock_browser|) for an
identifier under the cursor.
*:IDoc*
:IDoc {identifier} Open the Haddock entry for the unqualified
{identifier} in |haddock_browser|, suggesting possible
full qualifications.
*:MDoc*
:MDoc {module} Open the Haddock entry for {module} in
|haddock_browser| (with command-line completion for
the fully qualified module name).
*:FlagReference*
:FlagReference {s} Browse Users Guide Flag Reference for section {s}
(with command-line completion for section headers).
*haskellmode-editing*
4.3 Editing ~
*_.*
_. Fully qualify the unqualified name under the cursor
selecting full qualifications from a popup menu (GUI)
or via command-line completion (CLI).
*_iq* *_i*
_i _iq Add 'import [qualified] <module>(<identifier>)'
statement for the identifier under the cursor,
selecting fully qualified modules from a popup menu
(GUI) or via command-line completion (CLI), if the
identifier is not qualified. This currently adds one
import statement per call instead of merging into
existing import statements.
*_iqm* *_im*
_im Add 'import [qualified] <module>' statement for the
identifier under the cursor, selecting fully qualified
modules from a popup menu (GUI) or via command-line
completion (CLI), if the identifier is not qualified.
This currently adds one import statement per call
instead of merging into existing import statements.
*_ie*
_ie On an 'import <module>' line, in a correctly loadable
module, temporarily comment out import and use :make
'not in scope' errors to explicitly list imported
identifiers.
*haskellmode-XU* *haskellmode-user-completion*
CTRL-X CTRL-U User-defined insert mode name completion based on all
names known to the Haddock index, including package
names. Completions are presented in a popup menu which
also displays the fully qualified module from which
each entry may be imported.
CamelCode shortcuts are supported, meaning that
lower-case letters can be elided, using only
upper-case letters and module qualifier separators (.)
for disambiguation:
pSL -> putStrLn
C.E.t -> Control.Exception.t
C.M.MP -> Control.Monad.MonadPlus
To reduce unwanted matches, the first letter of such
shortcuts and the first letter after each '.' have to
match directly.
==============================================================================
*haskellmode-hpaste* *hpaste*
5. Hpaste Integration ~
This experimental feature allows browsing and posting to
http://hpaste.org, a Web-based pastebin tailored for Haskell code.
*:HpasteIndex*
:HpasteIndex Read the most recent entries from hpaste.org. Show an
index of the entries in a new buffer, where ',r' will
open the current highlighted entry [and ',p' will
annotate it with the current buffer].
*:HpastePostNew*
:HpastePostNew Submit current buffer as a new hpaste entry.
[This, and ',p' above, are temporarily disabled,
needs update to new hpaste.org layout]
==============================================================================
*haskellmode-resources*
6. Additional Resources ~
An quick screencast tour through of these plugins is available at:
http://projects.haskell.org/haskellmode-vim/screencasts.html
Other Haskell-related Vim plugins can be found here:
http://www.haskell.org/haskellwiki/Libraries_and_tools/Program_development#Vim
Make sure to read about Vim's other program-editing features in its online
|user-manual|. Also have a look at Vim tips and plugins at www.vim.org -
two other plugins I tend to use when editing Haskell are AlignPlugin.vim
(to line up regexps for definitions, keywords, comments, etc. in
consecutive lines) and surround.vim (to surround text with quotes,
brackets, parentheses, comments, etc.).
==============================================================================
vim:tw=78:ts=8:ft=help:
*supertab.txt*
Author: Eric Van Dewoestine <ervandew@gmail.com>
Original concept and versions up to 0.32 written by
Gergely Kontra <kgergely@mcl.hu>
This plugin is licensed under the terms of the BSD License. Please see
supertab.vim for the license in its entirety.
==============================================================================
Supertab *supertab*
1. Introduction |supertab-intro|
2. Supertab Usage |supertab-usage|
3. Supertab Options |supertab-options|
Default completion type |supertab-defaultcompletion|
Secondary default completion type |supertab-contextdefault|
Completion contexts |supertab-completioncontexts|
Context text |supertab-contexttext|
Context Discover |supertab-contextdiscover|
Example |supertab-contextexample|
Completion Duration |supertab-duration|
Preventing Completion After/Before... |supertab-preventcomplete|
Changing default mapping |supertab-forwardbackward|
Inserting true tabs |supertab-mappingtabliteral|
Enhanced longest match support |supertab-longestenhanced|
Preselecting the first entry |supertab-longesthighlight|
Mapping <cr> to end completion |supertab-crmapping|
Auto close the preview window |supertab-closepreviewonpopupclose|
Completion Chaining |supertab-completionchaining|
==============================================================================
1. Introduction *supertab-intro*
Supertab is a plugin which allows you to perform all your insert completion
(|ins-completion|) using the tab key.
Supertab requires Vim version 7.0 or above.
==============================================================================
2. Supertab usage *supertab-usage*
Using Supertab is as easy as hitting <Tab> or <S-Tab> (shift+tab) while in
insert mode, with at least one non whitespace character before the cursor, to
start the completion and then <Tab> or <S-Tab> again to cycle forwards or
backwards through the available completions.
Example ('|' denotes the cursor location):
bar
baz
b|<Tab> Hitting <Tab> here will start the completion, allowing you to
then cycle through the suggested words ('bar' and 'baz').
==============================================================================
3. Supertab Options *supertab-options*
Supertab is configured via several global variables that you can set in your
|vimrc| file according to your needs. Below is a comprehensive list of
the variables available.
Default Completion Type *supertab-defaultcompletion*
*g:SuperTabDefaultCompletionType*
g:SuperTabDefaultCompletionType (default value: "<c-p>")
Used to set the default completion type. There is no need to escape this
value as that will be done for you when the type is set.
Example: setting the default completion to 'user' completion:
let g:SuperTabDefaultCompletionType = "<c-x><c-u>"
Note: a special value of 'context' is supported which will result in
super tab attempting to use the text preceding the cursor to decide which
type of completion to attempt. Currently super tab can recognize method
calls or attribute references via '.', '::' or '->', and file path
references containing '/'.
let g:SuperTabDefaultCompletionType = "context"
/usr/l<tab> # will use filename completion
myvar.t<tab> # will use user completion if completefunc set,
# or omni completion if omnifunc set.
myvar-><tab> # same as above
When using context completion, super tab will fall back to a secondary default
completion type set by |g:SuperTabContextDefaultCompletionType|.
Note: once the buffer has been initialized, changing the value of this setting
will not change the default complete type used. If you want to change the
default completion type for the current buffer after it has been set, perhaps
in an ftplugin, you'll need to call SuperTabSetDefaultCompletionType like so,
supplying the completion type you wish to switch to:
call SuperTabSetDefaultCompletionType("<c-x><c-u>")
Secondary default completion type *supertab-contextdefault*
*g:SuperTabContextDefaultCompletionType*
g:SuperTabContextDefaultCompletionType (default value: "<c-p>")
Sets the default completion type used when g:SuperTabDefaultCompletionType is
set to 'context' and no completion type is returned by any of the configured
contexts.
Completion contexts *supertab-completioncontexts*
*g:SuperTabCompletionContexts*
g:SuperTabCompletionContexts (default value: ['s:ContextText'])
Sets the list of contexts used for context completion. This value should
be a list of function names which provide the context implementation.
When supertab starts the default completion, each of these contexts will be
consulted, in the order they were supplied, to determine the completion type
to use. If a context returns a completion type, that type will be used,
otherwise the next context in the list will be consulted. If after executing
all the context functions, no completion type has been determined, then the
value of g:SuperTabContextDefaultCompletionType will be used.
Built in completion contexts:
s:ContextText *supertab-contexttext*
The text context will examine the text near the cursor to decide which type
of completion to attempt. Currently the text context can recognize method
calls or attribute references via '.', '::' or '->', and file path
references containing '/'.
/usr/l<tab> # will use filename completion
myvar.t<tab> # will use user completion if completefunc set, or
# omni completion if omnifunc set.
myvar-><tab> # same as above
Supported configuration attributes:
g:SuperTabContextTextFileTypeExclusions
List of file types for which the text context will be skipped.
g:SuperTabContextTextOmniPrecedence
List of omni completion option names in the order of precedence that they
should be used if available. By default, user completion will be given
precedence over omni completion, but you can use this variable to give
omni completion higher precedence by placing it first in the list.
s:ContextDiscover *supertab-contextdiscover*
This context will use the 'g:SuperTabContextDiscoverDiscovery' variable to
determine the completion type to use. It will evaluate each value, in the
order they were defined, until a variable evaluates to a non-zero or
non-empty value, then the associated completion type is used.
Supported configuration properties:
g:SuperTabContextDiscoverDiscovery
List of variable:completionType mappings.
Example context configuration: *supertab-contextexample*
let g:SuperTabCompletionContexts = ['s:ContextText', 's:ContextDiscover']
let g:SuperTabContextTextOmniPrecedence = ['&omnifunc', '&completefunc']
let g:SuperTabContextDiscoverDiscovery =
\ ["&completefunc:<c-x><c-u>", "&omnifunc:<c-x><c-o>"]
In addition to the default completion contexts, you can plug in your own
implementation by creating a globally accessible function that returns
the completion type to use (eg. "\<c-x>\<c-u>").
function MyTagContext()
if filereadable(expand('%:p:h') . '/tags')
return "\<c-x>\<c-]>"
endif
" no return will result in the evaluation of the next
" configured context
endfunction
let g:SuperTabCompletionContexts =
\ ['MyTagContext', 's:ContextText', 's:ContextDiscover']
Note: supertab also supports the b:SuperTabCompletionContexts variable
allowing you to set the list of contexts separately for the current buffer,
like from an ftplugin for example.
Completion Duration *supertab-duration*
*g:SuperTabRetainCompletionDuration*
g:SuperTabRetainCompletionDuration (default value: 'insert')
Determines if, and for how long, the current completion type is retained.
The possible values include:
'completion' - The current completion type is only retained for the
current completion. Once you have chosen a completion
result or exited the completion mode, the default
completion type is restored.
'insert' - The current completion type is saved until you exit insert
mode (via ESC). Once you exit insert mode the default
completion type is restored. (supertab default)
'session' - The current completion type is saved for the duration of
your vim session or until you enter a different completion
mode.
Preventing completion after... *supertab-preventcomplete*
*g:SuperTabNoCompleteBefore*
*g:SuperTabNoCompleteAfter*
g:SuperTabNoCompleteBefore (default value: [])
g:SuperTabNoCompleteAfter (default value: ['^', '\s'])
These two variables are used to control when supertab will attempt completion
or instead fall back to inserting a literal <tab>. There are two possible ways
to define these variables:
1) by specifying a list of patterns which are tested against the text before
and after the current cursor position that when matched, prevent completion.
So if you don't want supertab to start completion at the start of a line,
after a comma, or after a space, you can set g:SuperTabNoCompleteAfter
to ['^', ',', '\s'].
2) by specifying a funcref to a global accessible function which expects
as parameter the text to be inspected (before or after) and, based on that (or
other factors), it returns 1 if completion must be prevented, 0 otherwise.
Note: That a buffer local version of these variables
(b:SuperTabNoCompleteBefore, b:SuperTabNoCompleteAfter) is also supported
should you wish to have different values depending on the file type for
instance.
Changing the default mapping *supertab-forwardbackward*
*g:SuperTabMappingForward*
*g:SuperTabMappingBackward*
g:SuperTabMappingForward (default value: '<tab>')
g:SuperTabMappingBackward (default value: '<s-tab>')
These two variables allow you to set the keys used to kick off the current
completion. By default this is <tab> and <s-tab>. To change to something
like <c-space> and <s-c-space>, you can add the following to your |vimrc|.
let g:SuperTabMappingForward = '<c-space>'
let g:SuperTabMappingBackward = '<s-c-space>'
Note: if the above does not have the desired effect (which may happen in
console version of vim), you can try the following mappings. Although the
backwards mapping still doesn't seem to work in the console for me, your
milage may vary.
let g:SuperTabMappingForward = '<nul>'
let g:SuperTabMappingBackward = '<s-nul>'
Inserting true tabs *supertab-mappingtabliteral*
*g:SuperTabMappingTabLiteral*
g:SuperTabMappingTabLiteral (default value: '<c-tab>')
Sets the key mapping used to insert a literal tab where supertab would
otherwise attempt to kick off insert completion. The default is '<c-tab>'
(ctrl-tab) which unfortunately might not work at the console. So if you are
using a console vim and want this functionality, you may have to change it to
something that is supported. Alternatively, you can escape the <tab> with
<c-v> (see |i_CTRL-V| for more infos).
Enhanced longest match support *supertab-longestenhanced*
*g:SuperTabLongestEnhanced*
g:SuperTabLongestEnhanced (default value: 0)
When enabled and 'longest' is in your |completeopt| setting, supertab will
provide an enhanced longest match support where typing one or more letters and
hitting tab again while in a completion mode will complete the longest common
match using the new text in the buffer.
For example, say you have a buffer with the following contents:
FooBarFoo
FooBar
Foo
FooBarBaz
And you then type F<tab>. Vim's builtin longest support will complete the
longest common text 'Foo' and offer 'FooBarFoo', 'FooBar', 'Foo', and
'FooBarBaz' as possible completions. With supertab's longest match
enhancement disabled, typing B<tab> while still in the completion mode will
end up completing 'FooBarBaz' or 'FooBarFoo' depending your settings, instead
of the next longest common match of 'FooBar'. With supertab's enhanced
longest match feature enabled, the typing of B<tab> will result in the next
longest text being completed.
Preselecting the first entry *supertab-longesthighlight*
*g:SuperTabLongestHighlight*
g:SuperTabLongestHighlight (default value: 0)
Sets whether or not to pre-highlight the first match when completeopt has the
popup menu enabled and the 'longest' option as well. When enabled, <tab> will
kick off completion and pre-select the first entry in the popup menu, allowing
you to simply hit <enter> to use it.
Mapping <cr> to end completion *supertab-crmapping*
*g:SuperTabCrMapping*
g:SuperTabCrMapping (default value: 1)
When enabled, <cr> will cancel completion mode preserving the current text.
Compatibility with other plugins:
- endwise: compatible
- delimitMate: not compatible (disabled if the delimitMate <cr> mapping is
detected.)
Note: if you have an insert expression mapping with a <cr> in it or an insert
abbreviation containing a <cr>, then supertab will not create a <cr> mapping
which could potentially cause problems with those.
Auto close the preview window *supertab-closepreviewonpopupclose*
*g:SuperTabClosePreviewOnPopupClose*
g:SuperTabClosePreviewOnPopupClose (default value: 0)
When enabled, supertab will attempt to close vim's completion preview window
when the completion popup closes (completion is finished or canceled).
Completion Chaining *supertab-completionchaining*
SuperTab provides the ability to chain one of the completion functions
(|completefunc| or |omnifunc|) together with a one of the default vim
completion key sequences (|ins-completion|), giving you the ability to attempt
completion with the first, and upon no results, fall back to the second.
To utilize this feature you need to call the SuperTabChain function where
the first argument is the name of a vim compatible |complete-function| and the
second is one of vim's insert completion (|ins-completion|) key bindings
(<c-p>, <c-n>, <c-x><c-]>, etc). Calling this function will set the current
buffer's |completefunc| option to a supertab provided implementation which
utilizes the supplied arguments to perform the completion. Since the
|completefunc| option is being set, this feature works best when also
setting |g:SuperTabDefaultCompletionType| to either "context" or "<c-x><c-u>".
Here is an example that can be added to your .vimrc which will setup the
supertab chaining for any filetype that has a provided |omnifunc| to first
try that, then fall back to supertab's default, <c-p>, completion:
autocmd FileType *
\ if &omnifunc != '' |
\ call SuperTabChain(&omnifunc, "<c-p>") |
\ call SuperTabSetDefaultCompletionType("<c-x><c-u>") |
\ endif
Note: This feature does not support chaining any other combination of
completions (2 or more completion functions, 2 or more key bindings, etc.). It
can only support 1 completion function followed by 1 key binding. This is due
to limitations imposed by vim's code completion implementation.
Note: If the |completefunc| or |omnifunc| use vim's |complete_add()| instead
of returning completion results as a list, then Supertab's completion chaining
won't work properly with it since Supertab uses the function result to
determine if it should fallback to the next completion type.
vim:tw=78:ts=8:ft=help:norl:
if exists("b:did_man")
finish
endif
let b:did_man = 1
setlocal nolist
setlocal readonly
setlocal buftype=nofile
setlocal bufhidden=hide
setlocal noswapfile
setlocal nomodifiable
setlocal nowrap
setlocal conceallevel=3
setlocal iskeyword+=,_
setlocal concealcursor=nvic
function! PrepManPager()
setlocal modifiable
if !empty ($MAN_PN)
silent %! col -b -x
file $MAN_PN
endif
setlocal nomodified
setlocal nomodifiable
endfunction
if !exists("*s:MMan")
function! s:MMan()
let l:word = substitute(expand('<cword>'), '.\b', '', 'g')
if winnr('$') == 1
vsplit
endif
exec 'Man' l:word
endfunction
autocmd BufEnter $MAN_PN call PrepManPager()
nnoremap q :q!<CR>
nnoremap <Space> <PageDown>
map <expr> <CR> winnr('$') == 1 ? ':vs<CR><C-]>' : '<C-]>'
function s:PrepManPager()
setlocal modifiable
if !empty ($MAN_PN)
"silent %! col -b -x
%s/.\b//g
file $MAN_PN
endif
setlocal nomodified
setlocal nomodifiable
endfunction
endif
"autocmd BufEnter $MAN_PN call PrepManPager()
nnoremap <buffer> q :q!<CR>
nnoremap <buffer> <Space> <PageDown>
nnoremap <buffer> <CR> :call <SID>MMan()<CR>
nnoremap <buffer> <c-]> :call <SID>MMan()<CR>
inoremap <buffer> [[ \begin{}<Esc>i
imap ]] <Plug>LatexCloseCurEnv
setlocal colorcolumn=+1
setlocal spell spelllang=en_gb
......
if has("gui_running")
if has("gui_gtk2")
set guifont=Ubuntu\ Mono\ 11
set guioptions-=r
endif
endif
if has("gui_running")
if has("gui_gtk2")
set guifont=Ubuntu\ Mono\ derivative\ Powerline\ 13
set guioptions-=r
endif
endif
let g:airline_powerline_fonts = 1
set textwidth=80
......@@ -67,3 +67,6 @@ Gavroche
Daneel
Anathem
bullwhip
manpage
manpages
filetype
......@@ -118,6 +118,7 @@ autocmd! User YouCompleteMe if !has('vim_starting') | call youcompleteme#Enable(
Plug 'godlygeek/tabular'
Plug 'vim-scripts/deb.vim'
Plug 'moon-musick/vim-logrotate'
call plug#end()
function! EnableYCM()
......@@ -143,7 +144,6 @@ set foldmethod=syntax
set foldlevelstart=3
let g:syntastic_cpp_compiler_options = ' -std=c++11'
let g:syntastic_python_python_exec = '/usr/bin/python3'
let g:airline#extensions#tabline#enabled = 1
"let g:LatexBox_latexmk_options = ' -xelatex '
"let g:LatexBox_latexmk_async = 1
"let g:LatexBox_latexmk_preview_continuously = 1
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment