Nvim Regex by @Rongzhou
Appearance
| (9 intermediate revisions by the same user not shown) | |||
| Line 1: | Line 1: | ||
== Generic == | |||
Newline to space | |||
<syntaxhighlight lang="text" copy> | |||
:%s#\n# #g | |||
</syntaxhighlight> | |||
Truncate line at arbitrary char count | |||
<syntaxhighlight lang="text" copy> | |||
:s#.\{}\zs.*## | |||
</syntaxhighlight> | |||
where the number of char is to be written between <code>{}</code> | |||
== Markdown /md == | == Markdown /md == | ||
| Line 13: | Line 26: | ||
== Katex == | == Katex == | ||
\[ \( <> $$ $ | \[ \( <> $$ $ delimiter change: | ||
<syntaxhighlight lang="text" copy> | <syntaxhighlight lang="text" copy> | ||
| Line 21: | Line 34: | ||
<syntaxhighlight lang="text" copy> | <syntaxhighlight lang="text" copy> | ||
:%s/\$\$\(\_.\{-}\)\$\$\|\$\(.\{-}\)\$/\=submatch(0) =~ '^\$\$' ? '\['.submatch(1).'\]' : '\('.submatch(2).'\)'/g | :%s/\$\$\(\_.\{-}\)\$\$\|\$\(.\{-}\)\$/\=submatch(0) =~ '^\$\$' ? '\['.submatch(1).'\]' : '\('.submatch(2).'\)'/g | ||
</syntaxhighlight> | |||
<code>vmatrix</code> > <code>\det pmatrix</code> | |||
<syntaxhighlight lang="text" copy> | |||
:%s#\\\(begin\|end\){vmatrix}#\=submatch(1)=='begin'?'\det\begin{pmatrix}':'\end{pmatrix}'#g | |||
</syntaxhighlight> | |||
Stripping extra labels, tags | |||
<syntaxhighlight lang=bash copy> | |||
:%s#\v\\(label|tag)\*?\s*\{[^}]*\}|\\(nonumber|notag)\s*##g | |||
</syntaxhighlight> | </syntaxhighlight> | ||
| Line 31: | Line 55: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
# > *: | ordered list (<code>#</code>) > to unordered list (<code>*</code>): | ||
<syntaxhighlight lang="text" copy> | <syntaxhighlight lang="text" copy> | ||
:%s#\##*#g | :%s#\##*#g | ||
</syntaxhighlight> | |||
literal digit list > to unordered list (<code>*</code>): | |||
<syntaxhighlight lang="text" copy> | |||
:%s#^\d.#*# | |||
</syntaxhighlight> | |||
<code>[[File:{filename}]]</code> > <code>[[File:{filename}|400px|center]]</code> | |||
<syntaxhighlight lang="text" copy> | |||
:%s/\[\[File:\([^]]*\)\]\]/[[File:\1\|400px\|center]]/g | |||
</syntaxhighlight> | |||
Plain Python code snippet > Pyodide | |||
<syntaxhighlight lang="text" copy> | |||
:%s#<syntaxhighlight lang="python" copy>#<syntaxhighlight lang="python" class="pyodide" copy>#g | |||
</syntaxhighlight> | </syntaxhighlight> | ||
Latest revision as of 10:01, 20 November 2026
Generic
Newline to space
:%s#\n# #g
Truncate line at arbitrary char count
:s#.\{}\zs.*##
where the number of char is to be written between {}
Markdown /md
Text <> list
:%s#^#- #
:%s#^- ##
Katex
\[ \( <> $$ $ delimiter change:
:%s/\(\\(\(.\{-}\)\\)\)\|\(\\\[\(\_.\{-}\)\\\]\)/\=submatch(1) != '' ? '$'.submatch(2).'$' : '$$'.submatch(4).'$$'/g
:%s/\$\$\(\_.\{-}\)\$\$\|\$\(.\{-}\)\$/\=submatch(0) =~ '^\$\$' ? '\['.submatch(1).'\]' : '\('.submatch(2).'\)'/g
vmatrix > \det pmatrix
:%s#\\\(begin\|end\){vmatrix}#\=submatch(1)=='begin'?'\det\begin{pmatrix}':'\end{pmatrix}'#g
Stripping extra labels, tags
:%s#\v\\(label|tag)\*?\s*\{[^}]*\}|\\(nonumber|notag)\s*##g
Wikitext
<syntaxhighlight ... inline></syntaxhighlight> > <code></code>:
:%s#<syntaxhighlight[^>]*inline>\(.\{-}\)<\/syntaxhighlight>#<code>\1</code>#g
ordered list (#) > to unordered list (*):
:%s#\##*#g
literal digit list > to unordered list (*):
:%s#^\d.#*#
[[File:{filename}]] > [[File:{filename}|400px|center]]
:%s/\[\[File:\([^]]*\)\]\]/[[File:\1\|400px\|center]]/g
Plain Python code snippet > Pyodide
:%s#<syntaxhighlight lang="python" copy>#<syntaxhighlight lang="python" class="pyodide" copy>#g