*matchit.txt* Extended "%" matching
For instructions on installing this file, type
:help matchit-install
inside Vim.
For Vim version 6.3. Last change: 2007 Aug 29
VIM REFERENCE MANUAL by Benji Fisher
*matchit* *matchit.vim*
1. Extended matching with "%" |matchit-intro|
2. Activation |matchit-activate|
3. Configuration |matchit-configure|
4. Supporting a New Language |matchit-newlang|
5. Known Bugs and Limitations |matchit-bugs|
The functionality mentioned here is a plugin, see |add-plugin|.
This plugin is only available if 'compatible' is not set.
You can avoid loading this plugin by setting the "loaded_matchit" variable
in your |vimrc| file: >
:let loaded_matchit = 1
{Vi does not have any of this}
==============================================================================
1. Extended matching with "%" *matchit-intro*
*matchit-%*
% Cycle forward through matching groups, such as "if", "else", "endif",
as specified by |b:match_words|.
*g%* *v_g%* *o_g%*
g% Cycle backwards through matching groups, as specified by
|b:match_words|. For example, go from "if" to "endif" to "else".
*[%* *v_[%* *o_[%*
[% Go to [count] previous unmatched group, as specified by
|b:match_words|. Similar to |[{|.
*]%* *v_]%* *o_]%*
]% Go to [count] next unmatched group, as specified by
|b:match_words|. Similar to |]}|.
*v_a%*
a% In Visual mode, select the matching group, as specified by
|b:match_words|, containing the cursor. Similar to |v_a[|.
A [count] is ignored, and only the first character of the closing
pattern is selected.
In Vim, as in plain vi, the percent key, |%|, jumps the cursor from a brace,
bracket, or paren to its match. This can be configured with the 'matchpairs'
option. The matchit plugin extends this in several ways:
You can match whole words, such as "if" and "endif", not just
single characters. You can also specify a |regular-expression|.
You can define groups with more than two words, such as "if",
"else", "endif". Banging on the "%" key will cycle from the "if" to
the first "else", the next "else", ..., the closing "endif", and back
to the opening "if". Nested structures are skipped. Using |g%| goes
in the reverse direction.
By default, words inside comments and strings are ignored, unless
the cursor is inside a comment or string when you type "%". If the
only thing you want to do is modify the behavior of "%" so that it
behaves this way, you do not have to define |b:match_words|, since the
script uses the 'matchpairs' option as well as this variable.
See |matchit-details| for details on what the script does, and |b:match_words|
for how to specify matching patterns.
MODES: *matchit-modes* *matchit-v_%* *matchit-o_%*
Mostly, % and related motions (|g%| and |[%| and |]%|) work just like built-in
|motion| commands in |Operator-pending| and |Visual| modes. However, you
cannot make these motions |linewise| or |characterwise|, since the |:omap|s
that define them start with "v" in order to make the default behavior
inclusive. (See |o_v|.) In other words, "dV%" will not work. The
work-around is to go through Visual mode: "V%d" will work.
LANGUAGES: *matchit-languages*
Currently, the following languages are supported: Ada, ASP with VBS, Csh,
DTD, Entity, Essbase, Fortran, HTML, JSP (same as HTML), LaTeX, Lua, Pascal,
SGML, Shell, Tcsh, Vim, XML. Other languages may already have support via
the default |filetype-plugin|s in the standard vim distribution.
To support a new language, see |matchit-newlang| below.
DETAILS: *matchit-details* *matchit-parse*
Here is an outline of what matchit.vim does each time you hit the "%" key. If
there are |backref|s in |b:match_words| then the first step is to produce a
version in which these back references have been eliminated; if there are no
|backref|s then this step is skipped. This step is called parsing. For
example, "\(foo\|bar\):end\1" is parsed to yield
"\(foo\|bar\):end\(foo\|bar\)". This can get tricky, especially if there are
nested groups. If debugging is turned on, the parsed version is saved as
|b:match_pat|.
*matchit-choose*
Next, the script looks for a word on the current line that matches the pattern
just constructed. It includes the patterns from the 'matchpairs' option.
The goal is to do what you expect, which turns out to be a little complicated.
The script follows these rules:
Insist on a match that ends on or after the cursor.
Prefer a match that includes the cursor position (that is, one that
starts on or before the cursor).
Prefer a match that starts as close to the cursor as possible.
If more than one pattern in |b:match_words| matches, choose the one
that is listed first.
Examples:
Suppose you >
:let b:match_words = '<:>,<tag>:</tag>'
< and hit "%" with the cursor on or before the "<" in "a <tag> is born".
The pattern '<' comes first, so it is preferred over '<tag>', which
also matches. If the cursor is on the "t", however, then '<tag>' is
preferred, because this matches a bit of text containing the cursor.
If the two groups of patterns were reversed then '<' would never be
preferred.
Suppose you >
:let b:match_words = 'if:end if'
< (Note the space!) and hit "%" with the cursor at the end of "end if".
Then "if" matches, which is probably not what you want, but if the
cursor starts on the "end " then "end if" is chosen. (You can avoid
this problem by using a more complicated pattern.)
If there is no match, the cursor does not move. (Before version 1.13 of the
script, it would fall back on the usual behavior of |%|). If debugging is
turned on, the matched bit of text is saved as |b:match_match| and the cursor
column of the start of the match is saved as |b:match_col|.
Next, the script looks through |b:match_words| (original and parsed versions)
for the group and pattern that match. If debugging is turned on, the group is
saved as |b:match_ini| (the first pattern) and |b:match_tail| (the rest). If
there are |backref|s then, in addition, the matching pattern is saved as
|b:match_word| and a table of translations is saved as |b:match_table|. If
there are |backref|s, these are determined from the matching pattern and
|b:match_match| and substituted into each pattern in the matching group.
The script decides whether to search forwards or backwards and chooses
arguments for the |searchpair()| function. Then, the cursor is moved to the
start of the match, and |searchpair()| is called. By default, matching
structures inside strings and comments are ignored. This can be changed by
setting |b:match_skip|.
==============================================================================
2. Activation *matchit-activate*
You can use this script as a plugin, by copying it to your plugin directory.
See |add-global-plugin| for instructions. You can also add a line to your
|vimrc| file, such as >
:source $VIMRUNTIME/macros/matchit.vim
or >
:runtime macros/matchit.vim
Either way, the script should start working the next time you start up Vim.
(Earlier versions of the script did nothing unless a |buffer-variable| named
|b:match_words| was defined. Even earlier versions contained autocommands
that set this variable for various file types. Now, |b:match_words| is
defined in many of the default |filetype-plugin|s instead.)
For a new language, you can add autocommands to the script or to your vimrc
file, but the recommended method is to add a line such as >
let b:match_words = '\<foo\>:\<bar\>'
to the |filetype-plugin| for your language. See |b:match_words| below for how
this variable is interpreted.
TROUBLESHOOTING *matchit-troubleshoot*
The script should work in most installations of Vim. It may not work if Vim
was compiled with a minimal feature set, for example if the |+syntax| option
was not enabled. If your Vim has support for syntax compiled in, but you do
not have |syntax| highlighting turned on, m
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
共52个文件
xpm:12个
png:12个
bmp:12个
eetop网友提供的vim verilog设计自动化工具,使用了,非常不错。 将压缩包解压后,将其中.vim/plugin/automatic.vim 拷贝到你home目录下相同目录中(.vim/plugin/),同时也拷贝.vim/after将home目录下.vim/, after目录下是一些图标,默认是linux平台下的图标。
资源推荐
资源详情
资源评论
收起资源包目录
eetop.cn_automatic_vim_2017_09_18.tar.gz (52个子文件)
automatic_vim_2017_09_18
.vimrc 1KB
.vim
ftplugin
verilog_systemverilog.vim 346B
syntax
verilog_systemverilog.vim 7KB
.netrwhist 126B
doc
matchit.txt 19KB
tags 5KB
plugin
matchit.vim 30KB
zoom.vim 2KB
automatic.vim 152KB
after
AddNeg.bmp 1KB
aln.xpm 569B
ShowCall.xpm 545B
AddBus.bmp 1KB
AddSig.bmp 1KB
alp.png 243B
alp.bmp 1KB
AddClk.bmp 1KB
alpn.xpm 570B
AddClk.xpm 540B
AddSig.xpm 540B
alnn.xpm 570B
AddBus.xpm 540B
AddNeg.xpm 596B
AddNeg.png 242B
AddBlk.png 190B
AddBus.png 229B
al.bmp 1KB
AddBlk.bmp 1KB
ShowCall.png 233B
AddClk.png 227B
aln.bmp 1KB
AddBlk.xpm 524B
ShowCall.bmp 1KB
al.xpm 568B
alpn.png 250B
aln.png 249B
ShowDef.bmp 1KB
al.png 250B
alpn.bmp 1KB
ShowDef.xpm 547B
alnn.bmp 1KB
AddSig.png 229B
alnn.png 263B
alp.xpm 569B
ShowDef.png 226B
nerdtree_plugin
fs_menu.vim 8KB
exec_menuitem.vim 2KB
ftdetect
verilog_systemverilog.vim 272B
indent
verilog_systemverilog.vim 9KB
automatic.vim.history.log 16KB
ctags_gen 248B
README 6KB
共 52 条
- 1
资源评论
- KSCNN2019-09-10下载下来学习下!
- 宁丁James2020-10-14这个东西挺好
Times_poem
- 粉丝: 3611
- 资源: 1
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功