Skip to content

Commit

Permalink
Use %() instead of ()
Browse files Browse the repository at this point in the history
%() doesn't capture subgroups, and should be a wee bit faster.
  • Loading branch information
arp242 committed Aug 12, 2019
1 parent 3ede1c8 commit 167c01a
Show file tree
Hide file tree
Showing 8 changed files with 14 additions and 14 deletions.
14 changes: 7 additions & 7 deletions README.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,19 @@ Currently supported filetype with their patterns:

Filetype What it matches Regexp
-------- --------------- ------
c Function/typedef opening brace \v(^\{|^\s@!.*\{$)
c Function/typedef opening brace \v%(^\{|^\s@!.*\{$)
css Selector ^[^ \t{}/]
git Commit in git log ^commit
go Top-level declaration \v^(func|type|var|const|import)
go Top-level declaration \v^%(func|type|var|const|import)
help Help tag definition \*[a-zA-Z0-9:_<> *-]\+\*
html Common block elements \v\<(head|body|style|script|div|ul|article|section|main|header|footer|h\d)[> ]
javascript Function declaration/expression \v^\s*(function\s*\w|var \w*\s+\=\s+function\s*\()
html Common block elements \v\<%(head|body|style|script|div|ul|article|section|main|header|footer|h\d)[> ]
javascript Function declaration/expression \v^\s*%(function\s*\w|var \w*\s+\=\s+function\s*\()
make Target ^[a-zA-Z0-9 _-]\+:
markdown Header and horizontal rule \v(^\=\=\=|^---|^#{1,6})
markdown Header and horizontal rule \v%(^\=\=\=|^---|^#{1,6})
ruby Function, class, or module \v^\s*%(def|class|module)>
sh Function declaration ^\w\+()[ \n]*{
sql CREATE and BEGIN \c\v^\s*(create|begin)>
vim Function/augroup definition \v(^\s*fu%[nction]>|aug%[roup] (end)@!)
sql CREATE and BEGIN \c\v^\s*%(create|begin)>
vim Function/augroup definition \v%(^\s*fu%[nction]>|aug%[roup] (end)@!)
yaml Top-level key ^\w\+:

This overrides mappings for some filetypes in Vim's standard distribution for
Expand Down
2 changes: 1 addition & 1 deletion after/ftplugin/c.vim
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@
" Seems to work surprisingly well on my C codebases.
"
" Alternate idea: /\v^(typedef|enum|struct)@!\w
call jumpy#map('\v(^\{|^\s@!.*\{$)')
call jumpy#map('\v%(^\{|^\s@!.*\{$)')
2 changes: 1 addition & 1 deletion after/ftplugin/go.vim
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
" Top-level declaration
call jumpy#map('\v^(func|type|var|const|import)')
call jumpy#map('\v^%(func|type|var|const|import)')
2 changes: 1 addition & 1 deletion after/ftplugin/html.vim
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
" Common block elements
call jumpy#map('\v\<(head|body|style|script|div|ul|article|section|main|header|footer|h\d)[> ]')
call jumpy#map('\v\<%(head|body|style|script|div|ul|article|section|main|header|footer|h\d)[> ]')
2 changes: 1 addition & 1 deletion after/ftplugin/javascript.vim
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
" Function declaration/expression
"
" At any indentation level, and only named ones, for obvious reasons.
call jumpy#map('\v^\s*(function\s*\w|var \w*\s+\=\s+function\s*\()')
call jumpy#map('\v^\s*%(function\s*\w|var \w*\s+\=\s+function\s*\()')
2 changes: 1 addition & 1 deletion after/ftplugin/markdown.vim
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
" Header and horizontal rule
call jumpy#map('\v(^\=\=\=|^---|^#{1,6})')
call jumpy#map('\v%(^\=\=\=|^---|^#{1,6})')
2 changes: 1 addition & 1 deletion after/ftplugin/sql.vim
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
" CREATE and BEGIN
call jumpy#map('\c\v^\s*(create|begin)>')
call jumpy#map('\c\v^\s*%(create|begin)>')
2 changes: 1 addition & 1 deletion after/ftplugin/vim.vim
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
" Function/augroup definition
call jumpy#map('\v(^\s*fu%[nction]>|aug%[roup] (end)@!)')
call jumpy#map('\v%(^\s*fu%[nction]>|aug%[roup] (end)@!)')

0 comments on commit 167c01a

Please sign in to comment.