Mercurial > vim
annotate runtime/pack/dist/opt/matchit/plugin/matchit.vim @ 26708:f0d7cb510ce3
Update runtime files
Commit: https://github.com/vim/vim/commit/fa3b72348d88343390fbe212cfc230fec1602fc2
Author: Bram Moolenaar <Bram@vim.org>
Date: Fri Dec 24 13:18:38 2021 +0000
Update runtime files
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Fri, 24 Dec 2021 14:30:04 +0100 |
parents | d4deb2e50667 |
children | ea044451c98f |
rev | line source |
---|---|
8720
9380c37723f8
commit https://github.com/vim/vim/commit/aedfcbe1e6c7df6edcd6756d7601bfdec7dd2087
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
1 " matchit.vim: (global plugin) Extended "%" matching |
15729 | 2 " Maintainer: Christian Brabandt |
26708 | 3 " Version: 1.18 |
4 " Last Change: 2020 Dec 23 | |
15729 | 5 " Repository: https://github.com/chrisbra/matchit |
6 " Previous URL:http://www.vim.org/script.php?script_id=39 | |
7 " Previous Maintainer: Benji Fisher PhD <benji@member.AMS.org> | |
8720
9380c37723f8
commit https://github.com/vim/vim/commit/aedfcbe1e6c7df6edcd6756d7601bfdec7dd2087
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
8 |
9380c37723f8
commit https://github.com/vim/vim/commit/aedfcbe1e6c7df6edcd6756d7601bfdec7dd2087
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
9 " Documentation: |
18456 | 10 " The documentation is in a separate file: ../doc/matchit.txt |
8720
9380c37723f8
commit https://github.com/vim/vim/commit/aedfcbe1e6c7df6edcd6756d7601bfdec7dd2087
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
11 |
9380c37723f8
commit https://github.com/vim/vim/commit/aedfcbe1e6c7df6edcd6756d7601bfdec7dd2087
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
12 " Credits: |
9380c37723f8
commit https://github.com/vim/vim/commit/aedfcbe1e6c7df6edcd6756d7601bfdec7dd2087
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
13 " Vim editor by Bram Moolenaar (Thanks, Bram!) |
9380c37723f8
commit https://github.com/vim/vim/commit/aedfcbe1e6c7df6edcd6756d7601bfdec7dd2087
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
14 " Original script and design by Raul Segura Acevedo |
9380c37723f8
commit https://github.com/vim/vim/commit/aedfcbe1e6c7df6edcd6756d7601bfdec7dd2087
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
15 " Support for comments by Douglas Potts |
9380c37723f8
commit https://github.com/vim/vim/commit/aedfcbe1e6c7df6edcd6756d7601bfdec7dd2087
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
16 " Support for back references and other improvements by Benji Fisher |
9380c37723f8
commit https://github.com/vim/vim/commit/aedfcbe1e6c7df6edcd6756d7601bfdec7dd2087
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
17 " Support for many languages by Johannes Zellner |
9380c37723f8
commit https://github.com/vim/vim/commit/aedfcbe1e6c7df6edcd6756d7601bfdec7dd2087
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
18 " Suggestions for improvement, bug reports, and support for additional |
9380c37723f8
commit https://github.com/vim/vim/commit/aedfcbe1e6c7df6edcd6756d7601bfdec7dd2087
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
19 " languages by Jordi-Albert Batalla, Neil Bird, Servatius Brandt, Mark |
9380c37723f8
commit https://github.com/vim/vim/commit/aedfcbe1e6c7df6edcd6756d7601bfdec7dd2087
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
20 " Collett, Stephen Wall, Dany St-Amant, Yuheng Xie, and Johannes Zellner. |
9380c37723f8
commit https://github.com/vim/vim/commit/aedfcbe1e6c7df6edcd6756d7601bfdec7dd2087
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
21 |
9380c37723f8
commit https://github.com/vim/vim/commit/aedfcbe1e6c7df6edcd6756d7601bfdec7dd2087
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
22 " Debugging: |
9380c37723f8
commit https://github.com/vim/vim/commit/aedfcbe1e6c7df6edcd6756d7601bfdec7dd2087
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
23 " If you'd like to try the built-in debugging commands... |
9380c37723f8
commit https://github.com/vim/vim/commit/aedfcbe1e6c7df6edcd6756d7601bfdec7dd2087
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
24 " :MatchDebug to activate debugging for the current buffer |
9380c37723f8
commit https://github.com/vim/vim/commit/aedfcbe1e6c7df6edcd6756d7601bfdec7dd2087
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
25 " This saves the values of several key script variables as buffer-local |
9380c37723f8
commit https://github.com/vim/vim/commit/aedfcbe1e6c7df6edcd6756d7601bfdec7dd2087
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
26 " variables. See the MatchDebug() function, below, for details. |
9380c37723f8
commit https://github.com/vim/vim/commit/aedfcbe1e6c7df6edcd6756d7601bfdec7dd2087
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
27 |
9380c37723f8
commit https://github.com/vim/vim/commit/aedfcbe1e6c7df6edcd6756d7601bfdec7dd2087
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
28 " TODO: I should think about multi-line patterns for b:match_words. |
9380c37723f8
commit https://github.com/vim/vim/commit/aedfcbe1e6c7df6edcd6756d7601bfdec7dd2087
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
29 " This would require an option: how many lines to scan (default 1). |
9380c37723f8
commit https://github.com/vim/vim/commit/aedfcbe1e6c7df6edcd6756d7601bfdec7dd2087
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
30 " This would be useful for Python, maybe also for *ML. |
9380c37723f8
commit https://github.com/vim/vim/commit/aedfcbe1e6c7df6edcd6756d7601bfdec7dd2087
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
31 " TODO: Maybe I should add a menu so that people will actually use some of |
9380c37723f8
commit https://github.com/vim/vim/commit/aedfcbe1e6c7df6edcd6756d7601bfdec7dd2087
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
32 " the features that I have implemented. |
9380c37723f8
commit https://github.com/vim/vim/commit/aedfcbe1e6c7df6edcd6756d7601bfdec7dd2087
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
33 " TODO: Eliminate the MultiMatch function. Add yet another argument to |
9380c37723f8
commit https://github.com/vim/vim/commit/aedfcbe1e6c7df6edcd6756d7601bfdec7dd2087
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
34 " Match_wrapper() instead. |
9380c37723f8
commit https://github.com/vim/vim/commit/aedfcbe1e6c7df6edcd6756d7601bfdec7dd2087
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
35 " TODO: Allow :let b:match_words = '\(\(foo\)\(bar\)\):\3\2:end\1' |
9380c37723f8
commit https://github.com/vim/vim/commit/aedfcbe1e6c7df6edcd6756d7601bfdec7dd2087
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
36 " TODO: Make backrefs safer by using '\V' (very no-magic). |
9380c37723f8
commit https://github.com/vim/vim/commit/aedfcbe1e6c7df6edcd6756d7601bfdec7dd2087
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
37 " TODO: Add a level of indirection, so that custom % scripts can use my |
9380c37723f8
commit https://github.com/vim/vim/commit/aedfcbe1e6c7df6edcd6756d7601bfdec7dd2087
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
38 " work but extend it. |
9380c37723f8
commit https://github.com/vim/vim/commit/aedfcbe1e6c7df6edcd6756d7601bfdec7dd2087
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
39 |
15334 | 40 " Allow user to prevent loading and prevent duplicate loading. |
15729 | 41 if exists("g:loaded_matchit") || &cp |
8720
9380c37723f8
commit https://github.com/vim/vim/commit/aedfcbe1e6c7df6edcd6756d7601bfdec7dd2087
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
42 finish |
9380c37723f8
commit https://github.com/vim/vim/commit/aedfcbe1e6c7df6edcd6756d7601bfdec7dd2087
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
43 endif |
15729 | 44 let g:loaded_matchit = 1 |
8720
9380c37723f8
commit https://github.com/vim/vim/commit/aedfcbe1e6c7df6edcd6756d7601bfdec7dd2087
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
45 |
9380c37723f8
commit https://github.com/vim/vim/commit/aedfcbe1e6c7df6edcd6756d7601bfdec7dd2087
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
46 let s:save_cpo = &cpo |
9380c37723f8
commit https://github.com/vim/vim/commit/aedfcbe1e6c7df6edcd6756d7601bfdec7dd2087
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
47 set cpo&vim |
9380c37723f8
commit https://github.com/vim/vim/commit/aedfcbe1e6c7df6edcd6756d7601bfdec7dd2087
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
48 |
15729 | 49 nnoremap <silent> <Plug>(MatchitNormalForward) :<C-U>call matchit#Match_wrapper('',1,'n')<CR> |
50 nnoremap <silent> <Plug>(MatchitNormalBackward) :<C-U>call matchit#Match_wrapper('',0,'n')<CR> | |
26708 | 51 xnoremap <silent> <Plug>(MatchitVisualForward) :<C-U>call matchit#Match_wrapper('',1,'v')<CR> |
52 \:if col("''") != col("$") \| exe ":normal! m'" \| endif<cr>gv`` | |
18456 | 53 xnoremap <silent> <Plug>(MatchitVisualBackward) :<C-U>call matchit#Match_wrapper('',0,'v')<CR>m'gv`` |
15729 | 54 onoremap <silent> <Plug>(MatchitOperationForward) :<C-U>call matchit#Match_wrapper('',1,'o')<CR> |
55 onoremap <silent> <Plug>(MatchitOperationBackward) :<C-U>call matchit#Match_wrapper('',0,'o')<CR> | |
56 | |
8720
9380c37723f8
commit https://github.com/vim/vim/commit/aedfcbe1e6c7df6edcd6756d7601bfdec7dd2087
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
57 " Analogues of [{ and ]} using matching patterns: |
15729 | 58 nnoremap <silent> <Plug>(MatchitNormalMultiBackward) :<C-U>call matchit#MultiMatch("bW", "n")<CR> |
59 nnoremap <silent> <Plug>(MatchitNormalMultiForward) :<C-U>call matchit#MultiMatch("W", "n")<CR> | |
18456 | 60 xnoremap <silent> <Plug>(MatchitVisualMultiBackward) :<C-U>call matchit#MultiMatch("bW", "n")<CR>m'gv`` |
61 xnoremap <silent> <Plug>(MatchitVisualMultiForward) :<C-U>call matchit#MultiMatch("W", "n")<CR>m'gv`` | |
15729 | 62 onoremap <silent> <Plug>(MatchitOperationMultiBackward) :<C-U>call matchit#MultiMatch("bW", "o")<CR> |
63 onoremap <silent> <Plug>(MatchitOperationMultiForward) :<C-U>call matchit#MultiMatch("W", "o")<CR> | |
64 | |
8720
9380c37723f8
commit https://github.com/vim/vim/commit/aedfcbe1e6c7df6edcd6756d7601bfdec7dd2087
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
65 " text object: |
18456 | 66 xmap <silent> <Plug>(MatchitVisualTextObject) <Plug>(MatchitVisualMultiBackward)o<Plug>(MatchitVisualMultiForward) |
26708 | 67 |
68 if !exists("g:no_plugin_maps") | |
69 nmap <silent> % <Plug>(MatchitNormalForward) | |
70 nmap <silent> g% <Plug>(MatchitNormalBackward) | |
71 xmap <silent> % <Plug>(MatchitVisualForward) | |
72 xmap <silent> g% <Plug>(MatchitVisualBackward) | |
73 omap <silent> % <Plug>(MatchitOperationForward) | |
74 omap <silent> g% <Plug>(MatchitOperationBackward) | |
75 | |
76 " Analogues of [{ and ]} using matching patterns: | |
77 nmap <silent> [% <Plug>(MatchitNormalMultiBackward) | |
78 nmap <silent> ]% <Plug>(MatchitNormalMultiForward) | |
79 xmap <silent> [% <Plug>(MatchitVisualMultiBackward) | |
80 xmap <silent> ]% <Plug>(MatchitVisualMultiForward) | |
81 omap <silent> [% <Plug>(MatchitOperationMultiBackward) | |
82 omap <silent> ]% <Plug>(MatchitOperationMultiForward) | |
83 | |
84 " Text object | |
85 xmap a% <Plug>(MatchitVisualTextObject) | |
86 endif | |
8720
9380c37723f8
commit https://github.com/vim/vim/commit/aedfcbe1e6c7df6edcd6756d7601bfdec7dd2087
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
87 |
9380c37723f8
commit https://github.com/vim/vim/commit/aedfcbe1e6c7df6edcd6756d7601bfdec7dd2087
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
88 " Call this function to turn on debugging information. Every time the main |
9380c37723f8
commit https://github.com/vim/vim/commit/aedfcbe1e6c7df6edcd6756d7601bfdec7dd2087
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
89 " script is run, buffer variables will be saved. These can be used directly |
9380c37723f8
commit https://github.com/vim/vim/commit/aedfcbe1e6c7df6edcd6756d7601bfdec7dd2087
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
90 " or viewed using the menu items below. |
9380c37723f8
commit https://github.com/vim/vim/commit/aedfcbe1e6c7df6edcd6756d7601bfdec7dd2087
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
91 if !exists(":MatchDebug") |
15729 | 92 command! -nargs=0 MatchDebug call matchit#Match_debug() |
8720
9380c37723f8
commit https://github.com/vim/vim/commit/aedfcbe1e6c7df6edcd6756d7601bfdec7dd2087
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
93 endif |
9380c37723f8
commit https://github.com/vim/vim/commit/aedfcbe1e6c7df6edcd6756d7601bfdec7dd2087
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
94 |
9380c37723f8
commit https://github.com/vim/vim/commit/aedfcbe1e6c7df6edcd6756d7601bfdec7dd2087
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
95 let &cpo = s:save_cpo |
9380c37723f8
commit https://github.com/vim/vim/commit/aedfcbe1e6c7df6edcd6756d7601bfdec7dd2087
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
96 unlet s:save_cpo |
9380c37723f8
commit https://github.com/vim/vim/commit/aedfcbe1e6c7df6edcd6756d7601bfdec7dd2087
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
97 |
15729 | 98 " vim:sts=2:sw=2:et: |