feat: add vim.md regex.md cheatsheet.

This commit is contained in:
jaywcjlove 2022-10-02 03:23:32 +08:00
parent f7f71e5070
commit 9ff36a3ac3
14 changed files with 1788 additions and 26 deletions

View File

@ -23,7 +23,9 @@ Quick Reference
[Semver](./docs/semver.md)<!--rehype:style=background: rgb(106 111 141/var(\-\-bg\-opacity));--> [Semver](./docs/semver.md)<!--rehype:style=background: rgb(106 111 141/var(\-\-bg\-opacity));-->
[Sketch](./docs/sketch.md)<!--rehype:style=background: rgb(223 148 0/var(\-\-bg\-opacity));--> [Sketch](./docs/sketch.md)<!--rehype:style=background: rgb(223 148 0/var(\-\-bg\-opacity));-->
[Jest](./docs/jest.md)<!--rehype:style=background: rgb(153 66 91/var(\-\-bg\-opacity));--> [Jest](./docs/jest.md)<!--rehype:style=background: rgb(153 66 91/var(\-\-bg\-opacity));-->
[RegEx](./docs/regex.md)<!--rehype:style=background: rgb(149 36 155/var(\-\-bg\-opacity));-->
[VSCode](./docs/vscode.md)<!--rehype:style=background: rgb(91 163 230/var(\-\-bg\-opacity));--> [VSCode](./docs/vscode.md)<!--rehype:style=background: rgb(91 163 230/var(\-\-bg\-opacity));-->
[Vim](./docs/vim.md)<!--rehype:style=background: rgb(9 150 8/var(\-\-bg\-opacity));-->
[XPath](./docs/xpath.md)<!--rehype:style=background: rgb(91 163 230/var(\-\-bg\-opacity));--> [XPath](./docs/xpath.md)<!--rehype:style=background: rgb(91 163 230/var(\-\-bg\-opacity));-->
<!--rehype:class=home-card--> <!--rehype:class=home-card-->

View File

@ -10,11 +10,11 @@ Jest 是一款优雅、简洁的 JavaScript 测试框架。
[Jest](https://jestjs.io/) 是一款优雅、简洁的 JavaScript 测试框架。 [Jest](https://jestjs.io/) 是一款优雅、简洁的 JavaScript 测试框架。
- 无需配置,大多数 JS 项目中即装即用,无需配置 - `无需配置` 大多数 JS 项目中即装即用,无需配置
- 优秀接口,从 it 到 expect - Jest 将工具包整合在一处。文档齐全、不断维护,非常不错。 - `优秀接口``it``expect` - Jest 将工具包整合在一处。文档齐全、不断维护,非常不错。
- 隔离的,并行进行测试,发挥每一丝算力。 - `隔离的` 并行进行测试,发挥每一丝算力。
- 快照, 轻松编写持续追踪大型对象的测试,并在测试旁或代码内显示实时快照。 - `快照` 轻松编写持续追踪大型对象的测试,并在测试旁或代码内显示实时快照。
- 代码覆盖, 无需其他操作,您仅需添加 --coverage 参数来生成代码覆盖率报告。 - `代码覆盖` 无需其他操作,您仅需添加 `--coverage` 参数来生成代码覆盖率报告。
### 测试结构 ### 测试结构
<!--rehype:wrap-class=col-span-2--> <!--rehype:wrap-class=col-span-2-->
@ -347,7 +347,7 @@ test('async test', (done) => {
}) })
``` ```
将断言包装在 try/catch 块中,否则 Jest 将忽略失败 将断言包装在 `try/catch` 块中,否则 `Jest` 将忽略失败
### Promises ### Promises
@ -361,7 +361,7 @@ test('async test', () => {
}) })
``` ```
从你的测试中 _返回_ 一个 Promise 从你的测试中 _返回_ 一个 `Promise`
## 模拟 ## 模拟
@ -628,7 +628,7 @@ describe.each([
}) })
``` ```
[describe.each() 文档](https://jestjs.io/docs/en/api#describeeachtablename-fn-timeout)、[test.each() 文档](https://jestjs.io/docs/en/api#testeachtablename-fn-timeout), [describe.each()](https://jestjs.io/docs/en/api#describeeachtablename-fn-timeout) 文档、[test.each()](https://jestjs.io/docs/en/api#testeachtablename-fn-timeout) 文档
跳过测试 跳过测试
---- ----
@ -671,7 +671,7 @@ test('第二个文本', () => {
}) })
``` ```
Node.js 和 Jest 会缓存你需要的模块。 要测试具有副作用的模块,您需要在测试之间重置模块注册表 `Node.js``Jest` 会缓存你需要的模块。 要测试具有副作用的模块,您需要在测试之间重置模块注册表
另见 另见

View File

@ -147,6 +147,35 @@ function () {}
<!--rehype:style=background:#e91e63;--> <!--rehype:style=background:#e91e63;-->
``` ```
### 快捷键样式
| Key | value |
| ---- | ---- |
| `快捷键` | 说明 |
| `快捷键` | 说明 |
<!--rehype:className=shortcuts-->
列表添加 `<!--rehype:className=shortcuts-->` 样式类,展示快捷键样式。
### 内置类样式
:- | -
:- | -
`shortcuts` | 快捷键样式
`wrap-text` | 超出换行
`show-header` | 展示表头
<!--rehype:className=shortcuts-->
### 颜色标签
:- | -
:- | -
`<yel>` | 黄色
`<pur>` | 紫色
`<code>`<code>\`\`</code> | 绿色
<!--rehype:className=shortcuts-->
布局 布局
--- ---

923
docs/regex.md Normal file
View File

@ -0,0 +1,923 @@
RegEX 备忘清单
===
正则表达式 (regex) 的快速参考,包括符号、范围、分组、断言和一些示例模式,以帮助您入门。
入门
--------
### 介绍
这是开始使用正则表达式(Regex)的快速备忘单。
- [Python 中的 Regex](#python-中的正则表达式) _(Quick Reference)_
- [JavaScript 中的 Regex](#javascript-中的正则表达式) _(Quick Reference)_
- [PHP 中的 Regex](#php中的正则表达式) _(Quick Reference)_
- [Java 中的 Regex](#java-中的正则表达式) _(Quick Reference)_
- [MySQL 中的 Regex](#mysql中的正则表达式) _(Quick Reference)_
- [Vim 中的 Regex](./vim#vim-搜索和替换) _(Quick Reference)_
- [在线 Regex 测试器](https://regex101.com/) _(regex101.com)_
<!--rehype:className=cols-2-->
### 字符类
范例 | 说明
:-|-
`[abc]` | 单个字符a、b 或 c
`[^abc]` | 一个字符除了a、b 或 c
`[a-z]` | 范围内的字符a-z
`[^a-z]` | 不在范围内的字符a-z
`[0-9]` | 范围内的数字0-9
`[a-zA-Z]` | 范围内的字符:<br>a-z 或 A-Z
`[a-zA-Z0-9]` | 范围内的字符:<br>a-z、A-Z 或 0-9
### 量词
范例 | 说明
:-|-
`a?` | 零个或一个`a`
`a*` | 零个或多个 `a`
`a+` | 一个或多个`a`
`[0-9]+` | `0-9`中的一个或多个
`a{3}` | 正好 `3``a`
`a{3,}` | 3个或更多的`a`
`a{3,6}` | `a``3``6` 之间
`a*` | 贪心量词
`a*?` | 惰性量词
`a*+` | 占有量词
### 常用元字符
- \^
- \{
- \+
- \<
- \[
- \*
- \)
- \>
- \.
- \(
- \|
- \$
- \\
- \?
<!--rehype:className=cols-3-->
使用 `\` 转义这些特殊字符
### 元序列
<!--rehype:wrap-class=row-span-4-->
范例 | 说明
:-|-
`.` | 任何单个字符
`\s` | 任何空白字符
`\S` | 任何非空白字符
`\d` | 任何数字,与 `[0-9]` 相同
`\D` | 任何非数字,与 `[^0-9]` 相同
`\w` | 任何单词字符
`\W` | 任何非单词字符
`\X` | 任何 Unicode 序列,包括换行符
`\C` | 匹配一个数据单元
`\R` | Unicode 换行符
`\v` | 垂直空白字符
`\V` | `\v` 的否定 - 除了换行符和垂直制表符之外的任何内容
`\h` | 水平空白字符
`\H` | `\h` 的否定
`\K` | 重置匹配
`\n` | 匹配第 `n` 个子模式
`\pX` | `Unicode` 属性 `X`
`\p{...}` | `Unicode` 属性或脚本类别
`\PX` | `\pX` 的否定
`\P{...}` | `\p` 的否定
`\Q...\E` | 引用;视为文字
`\k<name>` | 匹配子模式`name`
`\k'name'` | 匹配子模式`name`
`\k{name}` | 匹配子模式`name`
`\gn` | 匹配第 n 个子模式
`\g{n}` | 匹配第 n 个子模式
`\g<n>` | 递归第 n 个捕获组
`\g'n'` | 递归第 n 个捕获组。
`\g{-n}` | 匹配第 n 个相对前一个子模式
`\g<+n>` | 递归第 n 个相对即将到来的子模式
`\g'+n'` | 匹配第 n 个相对即将到来的子模式
`\g'letter'` | 递归命名捕获组 `字母`
`\g{letter}` | 匹配先前命名的捕获组 `字母`
`\g<letter>` | 递归命名捕获组 `字母`
`\xYY` | 十六进制字符 `YY`
`\x{YYYY}` | 十六进制字符 `YYYY`
`\ddd` | 八进制字符`ddd`
`\cY` | 控制字符 `Y`
`[\b]` | 退格字符
`\` | 使任何字符文字
### 锚点
范例 | 说明
:-|-
`\G` | 比赛开始
`^` | 字符串的开始
`$` | 字符串结束
`\A` | 字符串的开始
`\Z` | 字符串结束
`\z` | 字符串的绝对结尾
`\b` | 一个词的边界
`\B` | 非单词边界
### 替代
范例 | 说明
:-|-
`\0` | 完整的比赛内容
`\1` | 捕获组 `1` 中的内容
`$1` | 捕获组 `1` 中的内容
`${foo}` | 捕获组 `foo` 中的内容
`\x20` | 十六进制替换值
`\x{06fa}` | 十六进制替换值
`\t` | 标签
`\r` | 回车
`\n` | 新队
`\f` | 换页
`\U` | 大写转换
`\L` | 小写转换
`\E` | 终止任何转换
### 组构造
范例 | 说明
:-|-
`(...)` | 捕获所有封闭的东西
`(a\|b)` | 匹配 `a``b`
`(?:...)` | 匹配随附的所有内容
`(?>...)` | 原子组(非捕获)
`(?\|...)` | 重复的子模式组号
`(?#...)` | 注解
`(?'name'...)` | 命名捕获组
`(?<name>...)` | 命名捕获组
`(?P<name>...)` | 命名捕获组
`(?imsxXU)` | 内联修饰符
`(?(DEFINE)...)` | 在使用它们之前预定义模式
### 断言
:-|-
:-|-
`(?(1)yes\|no)` | 条件语句
`(?(R)yes\|no)` | 条件语句
`(?(R#)yes\|no)` | 递归条件语句
`(?(R&name)yes\|no)` | 条件语句
`(?(?=...)yes\|no)` | 有条件的前瞻
`(?(?<=...)yes\|no)` | 有条件的往后看
### 零宽度断言
:-|-
:-|-
`(?=...)` | 正先行断言
`(?!...)` | 负先行断言
`(?<=...)` | 正后发断言
`(?<!...)` | 负后发断言
零宽度断言 允许您在主模式之前向后看或之后lookahead匹配一个组而不会将其包含在结果中。
### 标志/修饰符
:-|-
:-|-
`g` | 全球的
`m` | 多行
`i` | 不区分大小写
`x` | 忽略空格
`s` | 单线
`u` | 统一码
`X` | 扩展
`U` | 不贪心
`A` | 锚
`J` | 重复的组名
### 递归
:-|-
:-|-
`(?R)` | 递归整个模式
`(?1)` | 递归第一个子模式
`(?+1)` | 递归第一个相对子模式
`(?&name)` | 递归子模式`name`
`(?P=name)` | 匹配子模式`name`
`(?P>name)` | 递归子模式`name`
### POSIX 字符类
<!--rehype:wrap-class=col-span-2-->
字符类 | 如同 | 意义
:-|-|-
| `[[:alnum:]]` | `[0-9A-Za-z]` | 字母和数字
| `[[:alpha:]]` | `[A-Za-z]` | 字母
| `[[:ascii:]]` | `[\x00-\x7F]` | ASCII 码 0-127
| `[[:blank:]]` | `[\t ]` | 仅空格或制表符
| `[[:cntrl:]]` | `[\x00-\x1F\x7F]` | 控制字符
| `[[:digit:]]` | `[0-9]` | 十进制数字
| `[[:graph:]]` | `[[:alnum:][:punct:]]` | 可见字符(不是空格)
| `[[:lower:]]` | `[a-z]` | 小写字母
| `[[:print:]]` | `[ -~] == [ [:graph:]]` | 可见字符
| `[[:punct:]]` | <code>[!"#$%&()*+,-./:;<=>?@[]^_\`{\|}~]</code> | 可见标点符号
| `[[:space:]]` | <code>[\t\n\v\f\r ]</code> | 空白
| `[[:upper:]]` | `[A-Z]` | 大写字母
| `[[:word:]]` | `[0-9A-Za-z_]` | 单词字符
| `[[:xdigit:]]` | `[0-9A-Fa-f]` | 十六进制数字
| `[[:<:]]` | `[\b(?=\w)]` | 词的开头
| `[[:>:]]` | `[\b(?<=\w)]` | 词尾
<!--rehype:className=show-header-->
### 控制动词
:-|-
:-|-
`(*ACCEPT)` | 控制动词
`(*FAIL)` | 控制动词
`(*MARK:NAME)` | 控制动词
`(*COMMIT)` | 控制动词
`(*PRUNE)` | 控制动词
`(*SKIP)` | 控制动词
`(*THEN)` | 控制动词
`(*UTF)` | 图案修饰符
`(*UTF8)` | 图案修饰符
`(*UTF16)` | 图案修饰符
`(*UTF32)` | 图案修饰符
`(*UCP)` | 图案修饰符
`(*CR)` | 换行修饰符
`(*LF)` | 换行修饰符
`(*CRLF)` | 换行修饰符
`(*ANYCRLF)` | 换行修饰符
`(*ANY)` | 换行修饰符
`\R` | 换行修饰符
`(*BSR_ANYCRLF)` | 换行修饰符
`(*BSR_UNICODE)` | 换行修饰符
`(*LIMIT_MATCH=x)` | 正则表达式引擎修饰符
`(*LIMIT_RECURSION=d)` | 正则表达式引擎修饰符
`(*NO_AUTO_POSSESS)` | 正则表达式引擎修饰符
`(*NO_START_OPT)` | 正则表达式引擎修饰符
正则表达式示例
--------------
### 字符串
范例 | 说明
:-|-
`ring ` | 匹配 <yel>ring</yel> sp<yel>ring</yel>board 等。
`. ` | 匹配 <yel>a</yel><yel>9</yel><yel>+</yel> 等。
`h.o ` | 匹配 <yel>hoo</yel><yel>h2o</yel><yel>h/o</yel> 等。
`ring\? ` | 匹配 <yel>ring?</yel>
`\(quiet\) ` | 匹配<yel>(安静)</yel>
`c:\\windows ` | 匹配 <yel>c:\windows</yel>
使用 `\` 搜索这些特殊字符:<br> `[ \ ^ $ . | ? * + ( ) { }`
### 备择方案
范例 | 说明
:-|-
`cat\|dog ` | 匹配 <yel>cat</yel><yel>dog</yel>
`id\|identity ` | 匹配 <yel>id</yel><yel>id</yel>entity
`identity\|id ` | 匹配 <yel>id</yel><yel>identity</yel>
当替代品重叠时,命令从长到短
### 字符类
范例 | 说明
:-|-
`[aeiou]` | 匹配任何元音
`[^aeiou]` | 匹配一个非元音
`r[iau]ng` | 匹配<yel>ring</yel>、w<yel>rang</yel>le、sp<yel>rung</yel>等。
`gr[ae]y` | 匹配 <yel>gray</yel><yel>grey</yel>
`[a-zA-Z0-9]` | 匹配任何字母或数字
`[ ]` 中总是转义 `. \ ]` 有时是 `^ - .`
### 速记类
范例 | 说明
:-|-
`\w ` | “单词”字符 <br> _(字母、数字或下划线)_
`\d ` | 数字
`\s ` | 空格 <br> _(空格、制表符、vtab、换行符)_
`\W, \D, or \S ` | 不是单词、数字或空格
`[\D\S] ` | 表示不是数字或空格,两者都匹配
`[^\d\s] ` | 禁止数字和空格
### 出现次数
范例 | 说明
:-|-
`colou?r` | 匹配 <yel>color</yel><yel>color</yel>
`[BW]ill[ieamy's]*` | 匹配 <yel>Bill</yel><yel>Willy</yel><yel>William's</yel> 等。
`[a-zA-Z]+` | 匹配 1 个或多个字母
`\d{3}-\d{2}-\d{4}` | 匹配 SSN
`[a-z]\w{1,7}` | 匹配 UW NetID
### 贪婪与懒惰
范例 | 说明
:-|-
`* + {n,}`<br>_greedy_ | 尽可能匹配
`<.+> ` | 在 <yel>\<b>bold\<\/b></yel> 中找到 1 个大匹配项
`*? +? {n,}?`<br>_lazy_ | 尽可能少匹配
`<.+?>` | 在 \<<yel>b</yel>>bold\<<yel>\/b</yel>> 中找到 2 个匹配项
### 范围
<!--rehype:wrap-class=col-span-2-->
范例 | 说明
:-|-
`\b ` | “单词”边缘(非“单词”字符旁边)
`\bring ` | 单词以“ring”开头例如 <yel>ringtone</yel>
`ring\b ` | 单词以“ring”结尾例如 <yel>spring</yel>
`\b9\b ` | 匹配单个数字 <yel>9</yel>,而不是 19、91、99 等。
`\b[a-zA-Z]{6}\b ` | 匹配 6 个字母的单词
`\B ` | 不是字边
`\Bring\B ` | 匹配 <yel>springs</yel><yel>wringer</yel>
`^\d*$ ` | 整个字符串必须是数字
`^[a-zA-Z]{4,20}$` | 字符串必须有 4-20 个字母
`^[A-Z] ` | 字符串必须以大写字母开头
`[\.!?"')]$ ` | 字符串必须以终端标点结尾
### 修饰
范例 | 说明
:-|-
`(?i)`[a-z]*`(?-i)` | 忽略大小写开/关
`(?s)`.*`(?-s)` | 匹配多行(导致 . 匹配换行符)
`(?m)`^.*;$`(?-m)` | <yel>^</yel> & <yel>$</yel> 匹配行不是整个字符串
`(?x)` | #free-spacing 模式,此 EOL 注释被忽略
`(?-x)` | 自由空间模式关闭
/regex/`ismx` | 修改整个字符串的模式
### 组
范例 | 说明
:-|-
`(in\|out)put ` | 匹配 <yel>input</yel><yel>output</yel>
`\d{5}(-\d{4})?` | 美国邮政编码 _(“+ 4”可选)_
如果组后匹配失败,解析器会尝试每个替代方案。
<br>
可能导致灾难性的回溯。
### 反向引用
范例 | 说明
:-|-
`(to) (be) or not \1 \2` | 匹配 <yel>to be or not to be</yel>
`([^\s])\1{2}` | 匹配非空格,然后再相同两次 &nbsp; <yel>aaa</yel>, <yel>...</yel>
`\b(\w+)\s+\1\b` | 匹配双字
### 非捕获组
范例 | 说明
:-|-
`on(?:click\|load)` | 快于:<br>`on(click\|load)`
尽可能使用非捕获或原子组
### 原子组
范例 | 说明
:-|-
`(?>red\|green\|blue)` | 比非捕获更快
`(?>id\|identity)\b` | 匹配 <yel>id</yel>,但不匹配 <yel>id</yel>entity
"id" 匹配,但 `\b` 在原子组之后失败,
解析器不会回溯到组以重试“身份”
<br>
<br>
如果替代品重叠,请从长到短命令。
### 零宽度断言 Lookaround(前后预查)
<!--rehype:wrap-class=col-span-2 row-span-2-->
范例 | 说明
:-|-
`(?= )` | 向前看,如果你能提前找到
`(?! )` | 向前看,如果你找不到前面
`(?<= )` | 向后看,如果你能找到后面
`(?<! )` | 向后看,如果你找不到后面
`\b\w+?(?=ing\b)` | 匹配 <yel>warbl</yel>ing, <yel>str</yel>ing, <yel>fish</yel>ing, ...
`\b(?!\w+ing\b)\w+\b` | 不以“ing”结尾的单词
`(?<=\bpre).*?\b ` | 匹配 pre<yel>tend</yel>、pre<yel>sent</yel>、pre<yel>fix</yel>、...
`\b\w{3}(?<!pre)\w*?\b` | 不以“pre”开头的词
`\b\w+(?<!ing)\b` | 匹配不以“ing”结尾的单词
### If-then-else
匹配 `Mr.``Ms.` 如果单词 `her` 稍后在字符串中
```
M(?(?=.*?\bher\b)s|r)\.
```
需要环顾 IF 条件
Python 中的正则表达式
---------------
### 入门
导入正则表达式模块
```python
import re
```
### 实例
<!--rehype:wrap-class=col-span-2 row-span-3-->
#### re.search()
```python
>>> sentence = 'This is a sample string'
>>> bool(re.search(r'this', sentence, flags=re.I))
True
>>> bool(re.search(r'xyz', sentence))
False
```
#### re.findall()
```python
>>> re.findall(r'\bs?pare?\b', 'par spar apparent spare part pare')
['par', 'spar', 'spare', 'pare']
>>> re.findall(r'\b0*[1-9]\d{2,}\b', '0501 035 154 12 26 98234')
['0501', '154', '98234']
```
#### re.finditer()
```python
>>> m_iter = re.finditer(r'[0-9]+', '45 349 651 593 4 204')
>>> [m[0] for m in m_iter if int(m[0]) < 350]
['45', '349', '4', '204']
```
#### re.split()
```python
>>> re.split(r'\d+', 'Sample123string42with777numbers')
['Sample', 'string', 'with', 'numbers']
```
#### re.sub()
```python
>>> ip_lines = "catapults\nconcatenate\ncat"
>>> print(re.sub(r'^', r'* ', ip_lines, flags=re.M))
* catapults
* concatenate
* cat
```
#### re.compile()
```python
>>> pet = re.compile(r'dog')
>>> type(pet)
<class '_sre.SRE_Pattern'>
>>> bool(pet.search('They bought a dog'))
True
>>> bool(pet.search('A cat crossed their path'))
False
```
### 函数
函数 | 说明
:-|-
`re.findall` | 返回包含所有匹配项的列表
`re.finditer` | 返回一个可迭代的匹配对象(每个匹配一个)
`re.search` | 如果字符串中的任何位置存在匹配项,则返回 Match 对象
`re.split` | 返回一个列表,其中字符串在每次匹配时被拆分
`re.sub` | 用字符串替换一个或多个匹配项
`re.compile` | 编译正则表达式模式供以后使用
`re.escape` | 返回所有非字母数字反斜杠的字符串
### Flags 标志
:- | - | -
:- | - | -
`re.I` | `re.IGNORECASE` | 忽略大小写
`re.M` | `re.MULTILINE` | 多行
`re.L` | `re.LOCALE` | 使 `\w``\b``\s` _locale 依赖_
`re.S` | `re.DOTALL` | 点匹配所有 _包括换行符_
`re.U` | `re.UNICODE` | 使 `\w``\b``\d``\s` _unicode 依赖_
`re.X` | `re.VERBOSE` | 可读风格
JavaScript 中的正则表达式
---------------
### test()
```javascript
let textA = 'I like APPles very much';
let textB = 'I like APPles';
let regex = /apples$/i
// Output: false
console.log(regex.test(textA));
// Output: true
console.log(regex.test(textB));
```
### search()
```javascript
let text = 'I like APPles very much';
let regexA = /apples/;
let regexB = /apples/i;
// Output: -1
console.log(text.search(regexA));
// Output: 7
console.log(text.search(regexB));
```
### exec()
```javascript
let text = 'Do you like apples?';
let regex= /apples/;
// Output: apples
console.log(regex.exec(text)[0]);
// Output: Do you like apples?
console.log(regex.exec(text).input);
```
### match()
```javascript
let text = 'Here are apples and apPleS';
let regex = /apples/gi;
// Output: [ "apples", "apPleS" ]
console.log(text.match(regex));
```
### split()
<!--rehype:wrap-class=col-span-2-->
```javascript
let text = 'This 593 string will be brok294en at places where d1gits are.';
let regex = /\d+/g
// Output: [ "This ", " string will be brok", "en at places where d", "gits are." ]
console.log(text.split(regex))
```
### matchAll()
```javascript
let regex = /t(e)(st(\d?))/g;
let text = 'test1test2';
let array = [...text.matchAll(regex)];
// Output: ["test1", "e", "st1", "1"]
console.log(array[0]);
// Output: ["test2", "e", "st2", "2"]
console.log(array[1]);
```
### replace()
```javascript {.wrap}
let text = 'Do you like aPPles?';
let regex = /apples/i
// Output: Do you like mangoes?
let result = text.replace(regex, 'mangoes');
console.log(result);
```
### replaceAll()
```javascript
let regex = /apples/gi;
let text = 'Here are apples and apPleS';
// Output: Here are mangoes and mangoes
let result = text.replaceAll(regex, "mangoes");
console.log(result);
```
<!--rehype:className=wrap-text-->
PHP中的正则表达式
------------
### 函数
<!--rehype:wrap-class=col-span-2-->
:- | -
:- | -
`preg_match()` | 执行正则表达式匹配
`preg_match_all()` | 执行全局正则表达式匹配
`preg_replace_callback()` | 使用回调执行正则表达式搜索和替换
`preg_replace()` | 执行正则表达式搜索和替换
`preg_split()` | 按正则表达式模式拆分字符串
`preg_grep()` | 返回与模式匹配的数组条目
### preg_replace
```php
$str = "Visit Microsoft!";
$regex = "/microsoft/i";
// Output: Visit QuickRef!
echo preg_replace($regex, "QuickRef", $str);
```
<!--rehype:className=wrap-text-->
### preg_match
```php
$str = "Visit QuickRef";
$regex = "#quickref#i";
// Output: 1
echo preg_match($regex, $str);
```
### preg_matchall
<!--rehype:wrap-class=col-span-2 row-span-2-->
```php
$regex = "/[a-zA-Z]+ (\d+)/";
$input_str = "June 24, August 13, and December 30";
if (preg_match_all($regex, $input_str, $matches_out)) {
// Output: 2
echo count($matches_out);
// Output: 3
echo count($matches_out[0]);
// Output: Array("June 24", "August 13", "December 30")
print_r($matches_out[0]);
// Output: Array("24", "13", "30")
print_r($matches_out[1]);
}
```
### preg_grep
```php
$arr = ["Jane", "jane", "Joan", "JANE"];
$regex = "/Jane/";
// Output: Jane
echo preg_grep($regex, $arr);
```
### preg_split
<!--rehype:wrap-class=col-span-2-->
```php
$str = "Jane\tKate\nLucy Marion";
$regex = "@\s@";
// Output: Array("Jane", "Kate", "Lucy", "Marion")
print_r(preg_split($regex, $str));
```
Java 中的正则表达式
-------------
### 风格
<!--rehype:wrap-class=col-span-2-->
#### 第一种方式
```java
Pattern p = Pattern.compile(".s", Pattern.CASE_INSENSITIVE);
Matcher m = p.matcher("aS");
boolean s1 = m.matches();
System.out.println(s1); // Outputs: true
```
#### 第二种方式
```java
boolean s2 = Pattern.compile("[0-9]+").matcher("123").matches();
System.out.println(s2); // Outputs: true
```
#### 第三种方式
```java
boolean s3 = Pattern.matches(".s", "XXXX");
System.out.println(s3); // Outputs: false
```
### 模式字段
:- | -
:- | -
`CANON_EQ` | 规范等价
`CASE_INSENSITIVE` | 不区分大小写的匹配
`COMMENTS` | 允许空格和注释
`DOTALL` | 圆点模式
`MULTILINE` | 多行模式
`UNICODE_CASE` | Unicode 感知大小写折叠
`UNIX_LINES` | Unix 行模式
### 方法
#### Pattern
- 模式编译 compile(字符串正则表达式 [,int flags])
- 布尔匹配 matches([字符串正则表达式,] CharSequence 输入)
- String[] 拆分 split(字符串正则表达式 [,int 限制])
- 字符串引用 quote(字符串 s)
#### 匹配器
- int start([int group | 字符串名称])
- int end([int group | 字符串名称])
- 布尔 find([int start])
- 字符 group([int 组 | 字符串名称])
- 匹配器重置 reset()
#### String
- boolean matches(String regex)
- String replaceAll(String regex, 字符串替换)
- String[] split(String regex[, int limit])
还有更多方法...
### 例子
<!--rehype:wrap-class=col-span-2-->
替换句子:
```java
String regex = "[A-Z\n]{5}$";
String str = "I like APP\nLE";
Pattern p = Pattern.compile(regex, Pattern.MULTILINE);
Matcher m = p.matcher(str);
// Outputs: I like Apple!
System.out.println(m.replaceAll("pple!"));
```
所有匹配的数组:
```java
String str = "She sells seashells by the Seashore";
String regex = "\\w*se\\w*";
Pattern p = Pattern.compile(regex, Pattern.CASE_INSENSITIVE);
Matcher m = p.matcher(str);
List<String> matches = new ArrayList<>();
while (m.find()) {
matches.add(m.group());
}
// Outputs: [sells, seashells, Seashore]
System.out.println(matches);
```
MySQL中的正则表达式
-------------
<!--rehype:body-class=cols-2-->
### 函数
函数名称 | 说明
:- | -
`REGEXP ` | 字符串是否匹配正则表达式
`REGEXP_INSTR() ` | 匹配正则表达式的子字符串的起始索引 <br>_注意仅限 MySQL 8.0+_
`REGEXP_LIKE() ` | 字符串是否匹配正则表达式 <br>_(注意:仅 MySQL 8.0+)_
`REGEXP_REPLACE()` | 替换匹配正则表达式的子字符串 <br>_注意仅限 MySQL 8.0+_
`REGEXP_SUBSTR() ` | 返回匹配正则表达式的子字符串 <br>_(注意:仅 MySQL 8.0+)_
### REGEXP
```sql {.wrap}
expr REGEXP pat
```
#### Examples
```sql
mysql> SELECT 'abc' REGEXP '^[a-d]';
1
mysql> SELECT name FROM cities WHERE name REGEXP '^A';
mysql> SELECT name FROM cities WHERE name NOT REGEXP '^A';
mysql> SELECT name FROM cities WHERE name REGEXP 'A|B|R';
mysql> SELECT 'a' REGEXP 'A', 'a' REGEXP BINARY 'A';
1 0
```
### REGEXP_REPLACE
```
REGEXP_REPLACE(expr, pat, repl[, pos[, occurrence[, match_type]]])
```
#### 例子
```sql
mysql> SELECT REGEXP_REPLACE('a b c', 'b', 'X');
a X c
mysql> SELECT REGEXP_REPLACE('abc ghi', '[a-z]+', 'X', 1, 2);
abc X
```
### REGEXP_SUBSTR
```
REGEXP_SUBSTR(expr, pat[, pos[, occurrence[, match_type]]])
```
#### 例子
```sql
mysql> SELECT REGEXP_SUBSTR('abc def ghi', '[a-z]+');
abc
mysql> SELECT REGEXP_SUBSTR('abc def ghi', '[a-z]+', 1, 3);
ghi
```
### REGEXP_LIKE
```
REGEXP_LIKE(expr, pat[, match_type])
```
#### 例子
```sql
mysql> SELECT regexp_like('aba', 'b+')
1
mysql> SELECT regexp_like('aba', 'b{2}')
0
mysql> # i: case-insensitive
mysql> SELECT regexp_like('Abba', 'ABBA', 'i');
1
mysql> # m: multi-line
mysql> SELECT regexp_like('a\nb\nc', '^b$', 'm');
1
```
### REGEXP_INSTR
``` {.wrap}
REGEXP_INSTR(expr, pat[, pos[, occurrence[, return_option[, match_type]]]])
```
#### 例子
```sql
mysql> SELECT regexp_instr('aa aaa aaaa', 'a{3}');
2
mysql> SELECT regexp_instr('abba', 'b{2}', 2);
2
mysql> SELECT regexp_instr('abbabba', 'b{2}', 1, 2);
5
mysql> SELECT regexp_instr('abbabba', 'b{2}', 1, 3, 1);
7
```

View File

@ -15,7 +15,6 @@ Semver 备忘清单
### Semver ### Semver
| - | - | | - | - |
|-----------------|------------------------| |-----------------|------------------------|
| `主版本号(MAJOR)` | 当你做了不兼容的 API 修改 | | `主版本号(MAJOR)` | 当你做了不兼容的 API 修改 |
@ -52,6 +51,7 @@ Semver 备忘清单
| `1` | 相同的 | | | `1` | 相同的 | |
| `*` | 任何版本 | | | `*` | 任何版本 | |
| `x` | 相同的 | | | `x` | 相同的 | |
<!--rehype:className=shortcuts-->
### 连字符范围 ### 连字符范围
<!--rehype:wrap-class=row-span-3--> <!--rehype:wrap-class=row-span-3-->
@ -59,20 +59,22 @@ Semver 备忘清单
| 范围 | 描述 | | 范围 | 描述 |
| --- | --- | | --- | --- |
| `1.2.3 - 2.3.4` | 是 `>=1.2.3 <=2.3.4` | | `1.2.3 - 2.3.4` | 是 `>=1.2.3 <=2.3.4` |
<!--rehype:className=show-header --> <!--rehype:className=shortcuts show-header-->
#### 部分向右 #### 部分向右
| 范围 | 描述 | | 范围 | 描述 |
| --- | --- | | --- | --- |
| `1.2.3 - 2.3` | 是 `>=1.2.3 <2.4.0` | | `1.2.3 - 2.3` | 是 `>=1.2.3 <2.4.0` |
| `1.2.3 - 2` | 是 `>=1.2.3 <3.0.0` | | `1.2.3 - 2` | 是 `>=1.2.3 <3.0.0` |
<!--rehype:className=shortcuts-->
#### 部分向左 #### 部分向左
| 范围 | 描述 | | 范围 | 描述 |
| --- | --- | | --- | --- |
| `1.2 - 2.3.0` | 是 `1.2.0 - 2.3.0` | | `1.2 - 2.3.0` | 是 `1.2.0 - 2.3.0` |
<!--rehype:className=shortcuts-->
当右侧为部分(例如,`2.3`)时,假定缺失的部分为`x`(例如,` 2.3.x`)。 当右侧为部分(例如,`2.3`)时,假定缺失的部分为`x`(例如,` 2.3.x`)。
@ -84,7 +86,7 @@ Semver 备忘清单
| --- | --- | | --- | --- |
| `>=0.14 <16` | 和 (空格分隔) | | `>=0.14 <16` | 和 (空格分隔) |
| `0.14.x \|\| 15.x.x` | 或 (双竖线分隔) | | `0.14.x \|\| 15.x.x` | 或 (双竖线分隔) |
<!--rehype:className=show-header --> <!--rehype:className=shortcuts show-header-->
### 预发布 ### 预发布
@ -100,6 +102,7 @@ Semver 备忘清单
| `~` | 意思是“相当接近” | | `~` | 意思是“相当接近” |
| `0.x.x` | 用于“初始开发” | | `0.x.x` | 用于“初始开发” |
| `1.x.x` | 表示定义了公共 API | | `1.x.x` | 表示定义了公共 API |
<!--rehype:className=shortcuts-->
另见 另见

View File

@ -20,6 +20,7 @@ Sketch 备忘清单
| `v` | (Vector Point) 向量点 | | `v` | (Vector Point) 向量点 |
| `p` | (Pencil) 铅笔 | | `p` | (Pencil) 铅笔 |
| `t` | (Text) 文本 | | `t` | (Text) 文本 |
<!--rehype:className=shortcuts-->
### 类型 ### 类型
@ -40,6 +41,7 @@ Sketch 备忘清单
| `Cmd + Shift + \` | 居中对齐 | | `Cmd + Shift + \` | 居中对齐 |
| `Cmd + Shift + }` | 右对齐 | | `Cmd + Shift + }` | 右对齐 |
| `Control + Cmd + Space` | 特殊字符 | | `Control + Cmd + Space` | 特殊字符 |
<!--rehype:className=shortcuts-->
### 画布视图 ### 画布视图
@ -50,7 +52,7 @@ Sketch 备忘清单
| `Cmd (+) +` | 放大 | | `Cmd (+) +` | 放大 |
| `Cmd (+) -` | 缩小 | | `Cmd (+) -` | 缩小 |
| `Cmd + 0` | 实际尺寸 | | `Cmd + 0` | 实际尺寸 |
| `Cmd + 1` | 中心布 | | `Cmd + 1` | 中心布 |
| `Cmd + 2` | 缩放选择 | | `Cmd + 2` | 缩放选择 |
| `Cmd + 3` | 中心选择 | | `Cmd + 3` | 中心选择 |
| `§` | 临时缩放到实际大小 | | `§` | 临时缩放到实际大小 |
@ -62,6 +64,7 @@ Sketch 备忘清单
| `Control + H` | 切换选择手柄 | | `Control + H` | 切换选择手柄 |
| `Control + X` | 切换像素网格 | | `Control + X` | 切换像素网格 |
| `Space + Drag` | 移动画布 | | `Space + Drag` | 移动画布 |
<!--rehype:className=shortcuts-->
### 窗口 ### 窗口
@ -74,6 +77,7 @@ Sketch 备忘清单
| `Alt + Cmd + T` | 切换工具栏 | | `Alt + Cmd + T` | 切换工具栏 |
| `Cmd + .` | 演示模式 | | `Cmd + .` | 演示模式 |
| `Control + Cmd + F` | 进入全屏 | | `Control + Cmd + F` | 进入全屏 |
<!--rehype:className=shortcuts-->
### 编辑形状 ### 编辑形状
@ -88,6 +92,7 @@ Sketch 备忘清单
| `Cmd + Arrows` | 更改对象大小 | | `Cmd + Arrows` | 更改对象大小 |
| `Shift + Cmd + Arrows` | 将单位更改 10 | | `Shift + Cmd + Arrows` | 将单位更改 10 |
| `1, 2, 3, 4` | 更改矢量点样式 | | `1, 2, 3, 4` | 更改矢量点样式 |
<!--rehype:className=shortcuts-->
### 编辑图层 ### 编辑图层
@ -103,6 +108,7 @@ Sketch 备忘清单
| `Shift + Cmd + R` | 旋转 | | `Shift + Cmd + R` | 旋转 |
| `F` | 切换填充 | | `F` | 切换填充 |
| `B` | 切换边框 | | `B` | 切换边框 |
<!--rehype:className=shortcuts-->
### 排列图层、组和画板 ### 排列图层、组和画板
@ -123,6 +129,7 @@ Sketch 备忘清单
| `Cmd + F` | 按名称查找图层 | | `Cmd + F` | 按名称查找图层 |
| `Fn + ↑` | 选择上方页面 | | `Fn + ↑` | 选择上方页面 |
| `Fn + ↓` | 选择下面的页面 | | `Fn + ↓` | 选择下面的页面 |
<!--rehype:className=shortcuts-->
另见 另见

View File

@ -457,12 +457,12 @@ switch(response.status) {
``` ```
### 断言函数 ### 断言函数
<!--rehype:wrap-class=col-span-2-->
描述影响当前范围的 CFA 更改的函数,因为它抛出而不是返回 false。 描述影响当前范围的 CFA 更改的函数,因为它抛出而不是返回 false。
```ts ```ts
function assertResponse(obj: any): function assertResponse(obj: any): asserts obj is SuccessResponse {
asserts obj is SuccessResponse {
if (!(obj instanceof SuccessResponse)) { if (!(obj instanceof SuccessResponse)) {
throw new Error('Not a success!') throw new Error('Not a success!')
} }

773
docs/vim.md Normal file
View File

@ -0,0 +1,773 @@
Vim 备忘清单
===
[Vim](http://www.vim.org/) 8.2 快速参考备忘单的有用集合,可帮助您更快地学习 vim 编辑器。
入门
---------------
### 运动图
<!--rehype:wrap-class=row-span-2-->
```bash
▼/▶ 光标 ▽/▷ 目标
```
#### 左右动作
```bash
╭┈┈┈┈┈┈┈┈┈┈┈┈┈ |
├┈┈┈┈┈┈┈┈┈┈┈┈┈ 0 $ ┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈╮
┆ ╭┈┈┈┈┈┈┈┈┈┈ ^ fe ┈┈┈┈┈┈┈┈╮ ┆
┆ ┆ ╭┈┈┈┈┈┈┈ Fo te ┈┈┈┈┈┈┈╮┆ ┆
┆ ┆ ┆╭┈┈┈┈┈┈ To 30| ┈┈┈╮ ┆┆ ┆
┆ ┆ ┆┆ ╭┈┈┈┈ ge w ┈┈┈╮ ┆ ┆┆ ┆
┆ ┆ ┆┆ ┆ ╭┈┈ b e ┈╮ ┆ ┆ ┆┆ ┆
┆ ┆ ┆┆ ┆ ┆ ╭h l╮ ┆ ┆ ┆ ┆┆ ┆
▽ ▽ ▽▽ ▽ ▽ ▽▼ ▼▽ ▽ ▽ ▽ ▽▽ ▽
echo "A cheatsheet from quickReference"
```
#### 上下动作
```bash
- SCREEN 1 START
╭┈┬┈┈┈┈┈┈┈┈┈▷ #!/usr/bin/python
┆ ┆ ╭┈┈┈▷
┆ ┆ ┆ print("Hello")
┆ ┆ { } ▶ print("Vim")
┆ ┆ ┆ print("!")
┆ ┆ └┈▷
┆ ┆ ╭┈┈┈┬┈┈┈▷ print("Welcome")
G gg H M L k j ▶ print("to")
┆ ┆ └┈▷ print("Quick Reference")
┆ ┆ print("/vim")
┆ ┆
┆ ╰┈┈┈┈┈▷
┆ - SCREEN 1 END
╰┈┈┈┈┈┈┈┈┈┈┈┈┈┈▷ print("SCREEN 2")
```
### 动作
<!--rehype:wrap-class=row-span-2-->
快捷方式 | 说明
:- | -
`h` \| `j` \| `k` \| `l` | 方向键
`<C-u>` _/_ `<C-d>` | 上/下半页
`<C-b>` _/_ `<C-f>` | 向上/向下翻页
<!--rehype:className=shortcuts-->
#### 字(词)
快捷方式 | 说明
:- | -
`b` _/_ `w` | 上一个/下一个单词
`ge` _/_ `e` | 上一个/下一个词尾
<!--rehype:className=shortcuts-->
#### 行
快捷方式 | 说明
:- | -
`0` _(zero)_ _/_ `$` | 行的开始/结束
`^` | 行开头 _(非空白)_
<!--rehype:className=shortcuts-->
#### 字符串
快捷方式 | 说明
:- | -
`Fe` _/_ `fe` | 移动到上一个/下一个`e`
`To` _/_ `to` | 在上一个/下一个`o`之前/之后移动
`\|` _/_ `n\|` | 转到第一个/`n`
<!--rehype:className=shortcuts-->
#### 文档
快捷方式 | 说明
:- | -
`gg` _/_ `G` | 第一行/最后一行
`:n` \| `nG` | 转到第 `n`
`}` _/_ `{` | 下一个/上一个空行
<!--rehype:className=shortcuts-->
#### 窗口
快捷方式 | 说明
:- | -
`H` _/_ `M` _/_ `L` | 上/中/下屏幕
`zt` _/_ `zz` _/_ `zb` | 上/中/下这条线
<!--rehype:className=shortcuts-->
### 插入模式
快捷方式 | 说明
:- | -
`i` _/_ `a` | 在光标之前/之后插入
`I` _/_ `A` | 插入行的开始/结束
`o` _/_ `O` _(letter)_ | 在下方/上方插入新行
`s` _/_ `S` | 删除字符/行并插入
`C` _/_ `cc` | 更改到/当前行的结尾
`gi` | 在最后一个插入点插入
`Esc` \| `<C-[>` | 退出插入模式
<!--rehype:className=shortcuts-->
### 保存和退出
快捷方式 | 说明
:- | -
`:w` | 保存
`:q` | 关闭文件
`:wq` \| `:x` \| `ZZ` | 保存并退出
`:wqa` | 保存并退出所有文件
`:q!` \| `ZQ` | 强制退出
`:qa` | 关闭所有文件
`:qa!` | 强制退出所有文件
`:w` new.txt | 写入`new.txt`
`:sav` new.txt | 保存并编辑`new.txt`
`:w` !sudo tee % | 写入只读文件
<!--rehype:className=shortcuts-->
### 正常模式
快捷方式 | 说明
:- | -
`r` | 替换一个字符
`R` | 进入替换模式
`u` _/_ `3u` | 撤消更改`1`/`3`
`U` | 在一行上撤消更改
`J` | 加入下一行
`<C-r>` _/_ 5 `<C-r>` | 重做更改`1`/`5`
<!--rehype:className=shortcuts-->
### 剪切和粘贴
<!--rehype:wrap-class=row-span-2-->
快捷方式 | 说明
:- | -
`x` | 删除字符 _(剪切)_
`p` _/_ `P` | 在之后/之前粘贴
`xp` | 交换两个字符
`D` | 删除到行尾 _(剪切)_
`dw` | 删除单词 _(剪切)_
`dd` | 删除线 _(剪切)_
`ddp` | 交换两条线
`yy` | 拉线 _(复制)_
`"*p` \| `"+p` | 从系统剪贴板粘贴
`"*y` \| `"+y` | 粘贴到系统剪贴板
<!--rehype:className=shortcuts-->
#### 在可视化模式下
快捷方式 | 说明
:- | -
| `d` _\|_ `x` | 删除选择 _(剪切)_
| `s` | 替换选择
| `y` | Yank 选择 _(复制)_
<!--rehype:className=shortcuts-->
### 重复
快捷方式 | 说明
:- | -
`.` | 重复上一个命令
`;` | 重复最新的 `f``t``F``T`
`,` | 重复最新的`f``t``F``T`颠倒
`&` | 重复最后一个`:s`
`@:` | 重复命令行命令
<!--rehype:className=shortcuts-->
### 可视化模式
快捷方式 | 说明
:- | -
`v` | 进入可视化模式
`V` | 进入视线模式
`<C-v>` | 进入可视化阻挡模式
`ggVG` | 选择所有文本
`>` _/_ `<` | 向右/向左移动文本
<!--rehype:className=shortcuts-->
### 宏
:- | -
:- | -
`qi` | 录制宏 `i`
`q` | 停止录制宏
`@i` | 运行宏`i`
`7@i` | 运行宏 `i` 7 次
`@@` | 重复上一个宏
<!--rehype:className=shortcuts-->
您可以为任何字母保存宏,而不仅仅是 `i`
Vim 运算符
---------
### 用法
<!--rehype:style=background:#d7a100;-->
快捷方式 | 说明
:- | -
`d` | <yel>w</yel>
运算符 | 动作
<!--rehype:className=shortcuts-->
将 [可用运算符](#可用运算符) 与 [动作](#动作) 结合使用以使用它们
### 可用运算符
<!--rehype:wrap-class=row-span-2-->
快捷方式 | 说明
:- | -
`d` | 删除
`y` | Yank _(复制)_
`c` | 更改 _(删除然后插入)_
`p` | 粘贴
`=` | 格式代码
`g~` | 切换案例
`gU` | 大写
`gu` | 小写
`>` | 右缩进
`<` | 左缩进
`!` | 通过外部程序过滤
<!--rehype:className=shortcuts-->
### 例子
<!--rehype:wrap-class=row-span-2-->
组合 | 说明
:- | -
`d`<yel>d</yel> | 删除当前行
`d`<yel>j</yel> | 删除两行
`d`<yel>w</yel> | 删除到下一个单词
`d`<yel>b</yel> | 删除到单词的开头
`d`<yel>fa</yel> | 删除直到 `a` 字符
`d`<yel>/hello</yel> | 删除直到 `hello`
`c`<yel>c</yel> | 更改当前行,与 `S` 同义
`y`<yel>y</yel> | 复制当前行
`>`<yel>j</yel> | 缩进 2 行
gg`d`<yel>G</yel> | 删除完整的文档
gg`=`<yel>G</yel> | 缩进一个完整的文档
gg`y`<yel>G</yel> | 复制整个文档
<!--rehype:className=show-header-->
### 计数
```shell
[数字] <运算符> <动作>
<运算符> [数字] <动作>
```
---
组合 | 说明
:- | -
2`d`<yel>d</yel> | 删除 `2`
6`y`<yel>y</yel> | 复制 `6`
`d`3<yel>w</yel> | 删除 `3`
`d`5<yel>j</yel> | 向下删除 `5`
`>`4<yel>k</yel> | 向上缩进 `4`
Vim 文本对象
------------
### 用法
<!--rehype:style=background:#d7a100;-->
快捷方式 | 说明
:- | -
`v` | &nbsp; &nbsp; &nbsp; &nbsp; <pur>i</pur> _/_ <pur>a</pur> | <yel>p</yel>
Operator | <pur>i</pur>nner(内部) _/_ <pur>a</pur>round(周围) | 文本对象
<!--rehype:className=shortcuts-->
文本块内部或周围使用 [operator](#可用运算符) 进行操作
### 文本对象
<!--rehype:wrap-class=row-span-2-->
快捷方式 | 说明
:- | -
<yel>p</yel> | 段落
<yel>w</yel> | 单词
<yel>W</yel> | WORD <br/> _(被空格包围)_
<yel>s</yel> | 句子
<yel>[</yel> <yel>(</yel> <yel>{</yel> <yel>\<</yel> | []、() 或 {} 块
<yel>]</yel> <yel>)</yel> <yel>}</yel> <yel>\></yel> | []、() 或 {} 块
<yel>'</yel> <yel>"</yel> <yel>\`</yel> | 带引号的字符串
<yel>b</yel> | 一个块 [(
<yel>B</yel> | [{中的一个块
<yel>t</yel> | 一个 HTML 标签块
查看 `:help text-objects`
### 删除
快捷方式 | 说明
:- | -
`d`<pur>i</pur><yel>w</yel> | 删除内词
`d`<pur>i</pur><yel>s</yel> | 删除内句
`d`<pur>i</pur><yel>"</yel> | 引号中删除
`d`<pur>a</pur><yel>"</yel> | 删除引号 _(包括引号)_
`d`<pur>i</pur><yel>p</yel> | 删除段落
### 选择
快捷方式 | 说明
:- | -
`v`<pur>i</pur><yel>"</yel> | 选择内引号“`...`{.underline}”
`v`<pur>a</pur><yel>"</yel> | 选择引号`"..."`{.underline}
`v`<pur>i</pur><yel>[</yel> | 选择内括号 [`...`{.underline}]
`v`<pur>a</pur><yel>[</yel> | 选择括号`[...]`{.underline}
`v`<pur>i</pur><yel>w</yel> | 选择内词
`v`<pur>i</pur><yel>p</yel> | 选择内部段落
`v`<pur>i</pur><yel>p</yel><pur>i</pur><yel>p</yel> | 选择更多段落
### 杂项
快捷方式 | 说明
:- | -
`c`<pur>i</pur><yel>w</yel> | 换内字
`c`<pur>i</pur><yel>"</yel> | 更改内部引号
`c`<pur>i</pur><yel>t</yel> | 更改内部标签 (HTML)
`c`<pur>i</pur><yel>p</yel> | 更改内部段落
`y`<pur>i</pur><yel>p</yel> | Yank 段落
`y`<pur>a</pur><yel>p</yel> | Yank 段落 _(包括换行符)_
Vim 多个文件
-------------
### Buffers (缓冲器)
:- | -
:- | -
`:e file` | 在新缓冲区中编辑文件
`:bn` | 转到下一个缓冲区
`:bp` | 转到上一个缓冲区
`:bd` | 从缓冲区列表中删除文件
`:b 5` | 打开缓冲区 #5
`:b file` | 按文件转到缓冲区
`:ls` | 列出所有打开的缓冲区
`:sp file` | 打开和拆分窗口
`:vs file` | 打开和垂直拆分窗口
`:hid` | 隐藏此缓冲区
`:wn` | 写入文件并移至下一个
`:tab ba` | 将所有缓冲区编辑为选项卡
### 窗口
:- | -
:- | -
`<C-w>` `s` | 拆分窗口
`<C-w>` `v` | 垂直拆分窗口
`<C-w>` `w` | 切换窗口
`<C-w>` `q` | 退出一个窗口
`<C-w>` `T` | 拆分成一个新标签
`<C-w>` `x` | 用下一个交换当前
`<C-w>` `-` _/_ `+` | 减少/增加高度
`<C-w>` `<` _/_ `>` | 减少/增加宽度
`<C-w>` `\|` | 最大宽度
`<C-w>` `=` | 同样高和宽
`<C-w>` `h` _/_ `l` | 转到左/右窗口
`<C-w>` `j` _/_ `k` | 转到上/下窗口
<!--rehype:className=shortcuts-->
### 选项卡
快捷方式 | 说明
:- | -
`:tabe [file]` | <yel>E</yel>在新选项卡中编辑文件
`:tabf [file]` | 如果在新选项卡中存在则打开
`:tabc` | <yel>C</yel>失去当前选项卡
`:tabo` | 关闭<yel>o</yel>其他选项卡
`:tabs` | 列出所有<yel>标签</yel>
`:tabr` | 转到第一个<yel>r</yel>标签
`:tabl` | 转到 <yel>l</yel>ast 选项卡
`:tabm 0` | <yel></yel>转到位置 `0`
`:tabn` | 转到 <yel>n</yel>ext 选项卡
`:tabp` | 转到<yel>p</yel>上一个标签
#### 正常模式
快捷方式 | 说明
:- | -
`gt` | 转到 <yel>n</yel>ext 选项卡
`gT` | 转到<yel>p</yel>上一个标签
`2gt` | 转到标签编号 `2`
Vim 搜索和替换
------------------
### 搜索
:- | -
:- | -
`/foo` | 向前搜索
`/foo\c` | 向前搜索 _(不区分大小写)_
`?foo` | 向后搜索
`/\v\d+` | 使用 [regex](./regex.md) 搜索
`n` | 下一个匹配的搜索模式
`N` | 上一场比赛
`*` | 向前搜索当前单词
`#` | 向后搜索当前单词
### 更换行
```vim
:[range]s/{pattern}/{str}/[flags]
```
---
:- | -
:- | -
`:s/old/new` | 先更换
`:s/old/new/g` | 全部替换
`:s/\vold/new/g` | 全部替换为 [regex](./regex.md)
`:s/old/new/gc` | 全部替换_(确认)_
`:s/old/new/i` | 先忽略大小写替换
`:2,6s/old/new/g` | 在 `2`-`6` 行之间替换
### 替换文件
```vim
:%s/{pattern}/{str}/[flags]
```
---
:- | -
:- | -
`:%s/old/new` | 先更换
`:%s/old/new/g` | 全部替换
`:%s/old/new/gc` | 全部替换 _(确认)_
`:%s/old/new/gi` | 全部替换 _(忽略大小写)_
`:%s/\vold/new/g` | 全部替换为 [regex](./regex.md)
### 范围
<!--rehype:wrap-class=row-span-2-->
:- | -
:- | -
`%` | 整个文件
`<,>` | 当前选择
`5` | 第 `5`
`5,10` | 第 `5` 行到第 `10`
`$` | 最后一行
`2,$` | 第 `2` 行到最后
`.` | 当前行
`,3` | 接下来的 `3`
`-3,` | 转发 `3`
### 全局命令
<!--rehype:wrap-class=row-span-2-->
```vim
:[range]g/{pattern}/[command]
```
---
:- | -
:- | -
`:g/foo/d` | 删除包含 `foo` 的行
`:g!/foo/d` | 删除不包含 `foo` 的行
`:g/^\s*$/d` | 删除所有空行
`:g/foo/t$` | 将包含 `foo` 的行复制到 EOF
`:g/foo/m$` | 将包含 `foo` 的行移动到 EOF
`:g/^/m0` | 反转文件
`:g/^/t.` | 复制每一行
### Inverse(逆) :g
```vim
:[range]v/{pattern}/[command]
```
---
:- | -
:- | -
`:v/foo/d` | 删除不包含`foo`的行 <br/> _(还有`:g!/foo/d`)_
### Flags(标志)
:- | -
:- | -
`g` | 替换所有出现
`i` | 忽略大小写
`I` | 不要忽略大小写
`c` | 确认每个替换
### 替换表达式(魔术)
:- | -
:- | -
`&` _\|_ `\0` | 替换为整个匹配的
`\1`...`\9` | 替换为 0-9 组
`\u` | 大写下一个字母
`\U` | 后面的大写字符
`\l` | 小写下一个字母
`\L` | 后面的字符小写
`\e` | `\u``\U``\l``\L` 的结尾
`\E` | `\u``\U``\l``\L` 的结尾
### 例子
<!--rehype:wrap-class=col-span-2-->
```shell
:s/a\|b/xxx\0xxx/g # 将 "a b" 修改为 "xxxaxxx xxxbxxx"
:s/test/\U& file/ # 将 "test" 修改为 "TEST FILE"
:s/\(test\)/\U\1\e file/ # 将 "test" 修改为 "TEST file"
:s/\v([abc])([efg])/\2\1/g # 将 "af fa bg" 修改为 "fa fa gb"
:s/\v\w+/\u\0/g # 将 "bla bla" 修改为 "Bla Bla"
:s/\v([ab])|([cd])/\1x/g # 将 "a b c d" 修改为 "ax bx x x"
:%s/.*/\L&/ # 将 "HTML" 修改为 "html"
:s/\v<(.)(\w*)/\u\1\L\2/g # 将单词的每个首字母大写
:%s/^\(.*\)\n\1/\1/ # 删除重复行
:%s/<\/\=\(\w\+\)\>/\U&/g # 将 HTML 标记转换为大写
:g/^pattern/s/$/mytext # 查找文本并将其附加到末尾
:g/pattern/norm! @i # 在匹配行上运行宏
/^\(.*\)\(\r\?\n\1\)\+$ # 查看重复行
/\v^(.*)(\r?\n\1)+$ # 查看重复行(非常神奇)
:v/./,/./-j # 将空行压缩成空行
:g/<p1>/,/<p2>/d # 从 <p1><p2> 包含删除
```
Vimdiff
-------
### 用法
<!--rehype:style=background:#d7a100;-->
```shell script
$ vimdiff file1 file2 [file3]
$ vim -d file1 file2 [file3]
```
### 编辑
<!--rehype:wrap-class=row-span-2-->
```
:[range]diffget [bufspec]
:[range]diffput [bufspec]
```
---
快捷方式 | 说明
:- | -
`do` _/_ `:diffget` | 获取get差异
`dp` _/_ `:diffput` | 放差价
`:dif` | 重新扫描差异
`:diffo` | 关闭差异模式
`:1,$+1diffget` | 获取所有差异
`ZQ` | 不做改动就退出
<!--rehype:className=shortcuts-->
请参阅:[范围](#范围)
### 折叠
<!--rehype:wrap-class=row-span-2-->
快捷方式 | 说明
:- | -
`zo` _/_ `zO` | 打开
`zc` _/_ `zC` | 关
`za` _/_ `zA` | 切换
`zv` | 这条线的打开折叠
`zM` | 关闭所有
`zR` | 打开所有
`zm` | 折叠更多 _(折叠级别 += 1)_
`zr` | 少折叠 _(折叠级别 -= 1)_
`zx` | 更新折叠
<!--rehype:className=shortcuts-->
### 跳跃
快捷方式 | 说明
:- | -
`]c` | 下一个区别
`[c` | 以前的区别
<!--rehype:className=shortcuts-->
各种各样的
-------------
### Case
<!--rehype:wrap-class=row-span-2-->
快捷方式 | 说明
:- | -
`vU` | _大写_ 字母
`vu` | _小写_ 字符
`~` | _切换案例_ 字符
`viw` `U` | _大写_
`viw` `u` | _小写_
`viw` `~` | _切换案例_
`VU` _/_ `gUU` | _大写_
`Vu` _/_ `guu` | _小写_
`V~` _/_ `g~~` | _切换案例_ 线
`gggUG` | _大写_ 所有文本
`ggguG` | _小写_ 所有文本
`ggg~G` | _切换大小写_ 所有文本
<!--rehype:className=shortcuts-->
### 跳跃
快捷方式 | 说明
:- | -
| `<C-o>` | 返回上一个
| `<C-i>` | 向前
| `gf` | 转到光标中的文件
| `ga` | 显示十六进制、ASCII值
<!--rehype:className=shortcuts-->
### 其他命令行
<!--rehype:wrap-class=row-span-2-->
:- | -
:- | -
`:h` | 帮助打开帮助视图
`:edit!` | 重新加载当前文件
`:2,8m0` | 将行 `2`-`8` 移动到 `0`
`:noh` | 清除搜索亮点
`:sort` | 排序行
`:ter` | 打开终端窗口
`:set paste` | 启用插入粘贴子模式
`:set nopaste` | 禁用插入粘贴子模式
`:cq` | 退出并出现错误<br/> _(正在中止 Git)_
### 导航
快捷方式 | 说明
:- | -
`%` | 最近/匹配的`{[()]}`
`[(` _\|_ `[{` | 上一个 `(``{`
`])` _\|_ `]{` | 下一个`)``}`
`[m` | 上一个方法开始
`[M` | 上一个方法结束
<!--rehype:className=shortcuts-->
### 计数器
快捷方式 | 说明
:- | -
`<C-a>` | 增加数量
`<C-x>` | 减少数量
<!--rehype:className=shortcuts-->
### 选项卡
<!--rehype:wrap-class=row-span-2 col-span-2-->
快捷方式 | 说明
:- | -
`:tag Classname` | 跳转到 Classname 的第一个定义
`<C-]>` | 跳转到定义
`g]` | 查看所有定义
`<C-t>` | 回到最后一个标签
`<C-o> <C-i>` | 后退前进
`:tselect Classname` | 查找类名的定义
`:tjump Classname` | 查找类名的定义 _(自动选择第一个)_
<!--rehype:className=shortcuts-->
### 格式化
:- | -
:- | -
| `:ce 8` | `8` 列之间的中心线 |
| `:ri 4` | 在 `4` 列右对齐行 |
| `:le` | 左对齐线 |
查看 `:help formatting`
### 标记
<!--rehype:wrap-class=row-span-4 col-span-2-->
快捷方式 | 说明
:- | -
<code>\`^</code> | 插入模式下光标的最后位置
<code>\`.</code> | 当前缓冲区的最后更改
<code>\`"</code> | 最后退出的当前缓冲区
<code>\`0</code> | 在上次编辑的文件中
<code>''</code> | 返回当前缓冲区中跳出的行
<code>\`\`</code> | 返回当前缓冲区中跳转的位置
<code>\`[</code> | 到先前更改或拉出的文本的开头
<code>\`]</code> | 到之前更改或拉出的文本的结尾
<code>\`&lt;</code>| 到最后一个可视化选择的开始
<code>\`&gt;</code>| 到最后一个可视化选择的结尾
`ma` | 将此光标位置标记为`a`
<code>\`a</code> | 跳转到光标位置`a`
`'a` | 跳转到位置为 `a` 的行首
<code>d'a</code> | 从当前行删除到标记 `a` 的行
<code>d\`a</code> | 从当前位置删除到标记 `a` 的位置
<code>c'a</code> | 将文本从当前行更改为 `a`
<code>y\`a</code> | 将文本从当前位置拉到 `a` 的位置
`:marks` | 列出所有当前标记
`:delm a` | 删除标记`a`
`:delm a-d` | 删除标记`a``b``c``d`
`:delm abc` | 删除标记`a``b``c`
<!--rehype:className=shortcuts-->
### 计算器
快捷方式 | 说明
:- | -
| `<C-r>` `=` 7*7 | 显示结果|
| `<C-r>` `=` 10/2 | 显示结果|
<!--rehype:className=shortcuts-->
在 INSERT 模式下执行此操作
### Shell
:- | -
:- | -
`:!<shell>` | 解释 Shell 命令
`:r!<shell>` | 读入shell的输出
`:r!date` | 插入日期
`:!!date` | 用日期替换当前行
### 命令行
快捷方式 | 说明
:- | -
`<C-r><C-w>` | 将当前单词插入命令行
`<C-r>"` | 从 `注册` 粘贴
`<C-x><C-f>` | 在插入模式下自动完成路径
<!--rehype:className=shortcuts-->
### 技巧
删除重复行
```shell
:sort | %!uniq -u
```
对文件中的行进行编号
```shell
:%!cat -n
```
将整个文档复制到剪贴板
```shell
:%w !pbcopy # Mac OS X
:%w !xclip -i -sel c # GNU/Linux
:%w !xsel -i -b # GNU/Linux
```
另见
---
- [搞得像IDE一样的 Vim](https://jaywcjlove.github.io/vim-web) _(github.io)_
- [Vim 官方网站](http://www.vim.org/) _(vim.org)_
- [Devhints](https://devhints.io/vim) _(devhints.io)_
- [Vim cheatsheet](https://vim.rtorr.com/) _(vim.rotrr.com)_
- [Vim documentation](http://vimdoc.sourceforge.net/htmldoc/) _(vimdoc.sourceforge.net)_
- [Interactive Vim tutorial](http://openvim.com/) _(openvim.com)_

View File

@ -15,6 +15,7 @@ VSCode 备忘清单
| `Ctrl` `Shift` `W` | 关闭窗口 | | `Ctrl` `Shift` `W` | 关闭窗口 |
| `Ctrl` `,` | 用户设置 | | `Ctrl` `,` | 用户设置 |
| `Ctrl` `K` `Ctrl` `S` | 键盘快捷键 | | `Ctrl` `K` `Ctrl` `S` | 键盘快捷键 |
<!--rehype:className=shortcuts-->
### 基本编辑 ### 基本编辑
<!--rehype:wrap-style=grid-row: span 2/span 2;--> <!--rehype:wrap-style=grid-row: span 2/span 2;-->
@ -46,6 +47,7 @@ VSCode 备忘清单
| `Ctrl` `/` | 切换行注释 | | `Ctrl` `/` | 切换行注释 |
| `Shift` `Alt` `A` | 切换块评论 | | `Shift` `Alt` `A` | 切换块评论 |
| `Alt` `Z` | 切换自动换行 | | `Alt` `Z` | 切换自动换行 |
<!--rehype:className=shortcuts-->
### 导航 ### 导航
@ -61,6 +63,7 @@ VSCode 备忘清单
| `Ctrl` `Shift` `Tab` | 浏览编辑组历史 | | `Ctrl` `Shift` `Tab` | 浏览编辑组历史 |
| `Alt` ` ←` _/_ `→` | 后退/前进 | | `Alt` ` ←` _/_ `→` | 后退/前进 |
| `Ctrl` `M` | 切换 Tab 移动焦点 | | `Ctrl` `M` | 切换 Tab 移动焦点 |
<!--rehype:className=shortcuts-->
### 搜索和替换 ### 搜索和替换
@ -74,6 +77,7 @@ VSCode 备忘清单
| `Ctrl` `D` | 将选择添加到下一个查找匹配项 | | `Ctrl` `D` | 将选择添加到下一个查找匹配项 |
| `Ctrl` `K` `Ctrl` `D` | 将最后一个选择移动到下一个查找匹配项 | | `Ctrl` `K` `Ctrl` `D` | 将最后一个选择移动到下一个查找匹配项 |
| `Alt` `C` _/_ `R` _/_ `W` | 切换区分大小写/正则表达式/整个单词 | | `Alt` `C` _/_ `R` _/_ `W` | 切换区分大小写/正则表达式/整个单词 |
<!--rehype:className=shortcuts-->
### 多光标和选择 ### 多光标和选择
@ -91,6 +95,7 @@ VSCode 备忘清单
| `Shift` `Alt` `<Drag>` | 列(框)选择 | | `Shift` `Alt` `<Drag>` | 列(框)选择 |
| `Ctrl` `Shift` `Alt` `<Arrow>` | 列(框)选择 | | `Ctrl` `Shift` `Alt` `<Arrow>` | 列(框)选择 |
| `Ctrl` `Shift` `Alt` `PgUp` _/_ `PgDn` | 列(框)选择页上/下 | | `Ctrl` `Shift` `Alt` `PgUp` _/_ `PgDn` | 列(框)选择页上/下 |
<!--rehype:className=shortcuts-->
### 丰富的语言编辑 ### 丰富的语言编辑
@ -108,6 +113,7 @@ VSCode 备忘清单
| `F2` | 重命名符号 | | `F2` | 重命名符号 |
| `Ctrl` `K` `Ctrl` `X` | 修剪尾随空格 | | `Ctrl` `K` `Ctrl` `X` | 修剪尾随空格 |
| `Ctrl` `K` `M` | 更改文件语言 | | `Ctrl` `K` `M` | 更改文件语言 |
<!--rehype:className=shortcuts-->
### 编辑管理 ### 编辑管理
@ -121,7 +127,7 @@ VSCode 备忘清单
| `Ctrl` `K` `Ctrl` `←` _/_ `→` | 专注于上一个/下一个编辑组 | | `Ctrl` `K` `Ctrl` `←` _/_ `→` | 专注于上一个/下一个编辑组 |
| `Ctrl` `Shift` `PgUp` _/_ `PgDn` | 向左/向右移动编辑器 | | `Ctrl` `Shift` `PgUp` _/_ `PgDn` | 向左/向右移动编辑器 |
| `Ctrl` `K` `←` _/_ `→` | 移动活动编辑器组 | | `Ctrl` `K` `←` _/_ `→` | 移动活动编辑器组 |
<!--rehype:className=shortcuts-->
### 文件管理 ### 文件管理
@ -141,6 +147,7 @@ VSCode 备忘清单
| `Ctrl` `K` `P` | 复制活动文件的路径 | | `Ctrl` `K` `P` | 复制活动文件的路径 |
| `Ctrl` `K` `R` | 在资源管理器中显示活动文件 | | `Ctrl` `K` `R` | 在资源管理器中显示活动文件 |
| `Ctrl` `K` `O` | 在新窗口/实例中显示活动文件 | | `Ctrl` `K` `O` | 在新窗口/实例中显示活动文件 |
<!--rehype:className=shortcuts-->
### 展示 ### 展示
@ -161,6 +168,7 @@ VSCode 备忘清单
| `Ctrl` `Shift` `V` | 打开 Markdown 预览 | | `Ctrl` `Shift` `V` | 打开 Markdown 预览 |
| `Ctrl` `K` `V` | 打开 Markdown 预览到一边 | | `Ctrl` `K` `V` | 打开 Markdown 预览到一边 |
| `Ctrl` `K` `Z` | Zen 模式Esc Esc 退出) | | `Ctrl` `K` `Z` | Zen 模式Esc Esc 退出) |
<!--rehype:className=shortcuts-->
### 调试 ### 调试
@ -180,3 +188,4 @@ VSCode 备忘清单
| `Ctrl` `↑` _/_ `↓` | 向上/向下滚动 | | `Ctrl` `↑` _/_ `↓` | 向上/向下滚动 |
| `Shift` `PgUp` _/_ `PgDn` | 向上/向下滚动页面 | | `Shift` `PgUp` _/_ `PgDn` | 向上/向下滚动页面 |
| `Ctrl` `Home` _/_ `End` | 滚动到顶部/底部 | | `Ctrl` `Home` _/_ `End` | 滚动到顶部/底部 |
<!--rehype:className=shortcuts-->

View File

@ -25,7 +25,6 @@
"recursive-readdir-files": "^2.3.0", "recursive-readdir-files": "^2.3.0",
"rehype-autolink-headings": "^6.1.1", "rehype-autolink-headings": "^6.1.1",
"rehype-document": "^6.1.0", "rehype-document": "^6.1.0",
"rehype-format": "^4.0.1",
"rehype-slug": "^5.0.1", "rehype-slug": "^5.0.1",
"remark-gemoji": "^7.0.1" "remark-gemoji": "^7.0.1"
} }

3
scripts/assets/regex.svg Normal file
View File

@ -0,0 +1,3 @@
<svg aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 14 14" height="1em" width="1em">
<path d="M8.676 5.214a5.533 5.533 0 0 0-.312-1.527c-.253-.729-.379-1.23-.379-1.505 0-.387.09-.68.268-.881A.892.892 0 0 1 8.933 1c.23 0 .43.1.602.301.17.2.256.487.256.858 0 .335-.1.803-.3 1.405a7.515 7.515 0 0 0-.358 1.65c.41-.26.777-.576 1.104-.947.506-.588.88-.952 1.126-1.093.245-.141.494-.212.747-.212.245 0 .45.086.613.257.171.163.257.36.257.59 0 .275-.123.52-.368.736-.246.216-.859.431-1.84.647a8.032 8.032 0 0 0-1.427.435c.387.2.859.353 1.416.457.9.163 1.487.368 1.762.613.282.245.423.513.423.803a.776.776 0 0 1-.256.58.793.793 0 0 1-.58.245c-.223 0-.472-.078-.747-.235-.267-.156-.632-.505-1.092-1.048a5.909 5.909 0 0 0-1.138-1.025c.015.423.1.884.257 1.382.267.877.401 1.476.401 1.795 0 .297-.089.55-.267.758-.179.2-.368.301-.569.301-.275 0-.524-.108-.747-.323-.156-.156-.234-.405-.234-.747 0-.357.085-.784.256-1.282.171-.505.28-.851.324-1.037.044-.193.085-.476.122-.847a6.15 6.15 0 0 0-1.148.97c-.543.61-.951.996-1.226 1.16a1.133 1.133 0 0 1-.602.178.9.9 0 0 1-.647-.257c-.178-.17-.268-.36-.268-.568 0-.186.075-.38.223-.58.157-.208.387-.38.692-.513.2-.09.657-.208 1.37-.357a7.284 7.284 0 0 0 1.35-.423 5.726 5.726 0 0 0-1.438-.469c-.914-.193-1.48-.367-1.695-.524-.334-.245-.502-.542-.502-.891 0-.201.082-.383.246-.547a.812.812 0 0 1 .59-.256c.246 0 .506.078.781.234.275.156.617.472 1.026.948.408.468.825.832 1.248 1.092M2.93 9.18c.54 0 .993.19 1.36.568.367.367.55.814.55 1.342 0 .528-.189.98-.567 1.36-.367.366-.815.55-1.343.55-.527 0-.98-.184-1.359-.55a1.884 1.884 0 0 1-.55-1.36c0-.54.183-.992.55-1.36.379-.367.832-.55 1.36-.55"/>
</svg>

After

Width:  |  Height:  |  Size: 1.6 KiB

3
scripts/assets/vim.svg Normal file
View File

@ -0,0 +1,3 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32" fill="currentColor" height="1em" width="1em">
<path d="M32 15.979h-.036l-5.755-5.755 5.734-5.885V1.948l-.865-.865H20.146l-.88.807v1.396L16.021.036V0L16 .021 15.979 0v.036L14.26 1.755l-.719-.719H2.713l-.849.927v2.51l.818.823h.964v7.078L.037 15.983H.001l.021.016-.021.021h.036l3.609 3.604v8.625l1.208.698h3.094l2.479-2.542 5.552 5.557v.036l.021-.021.021.021v-.036l3.344-3.344h.646a.352.352 0 0 0 .333-.24l.198-.568a.356.356 0 0 0-.052-.323l1.948-1.948-.813 2.615a.352.352 0 0 0 .234.443.242.242 0 0 0 .104.021h2.432a.365.365 0 0 0 .323-.219l.219-.526a.333.333 0 0 0-.005-.271.313.313 0 0 0-.193-.188.45.45 0 0 0-.13-.031h-.099l1.12-3.521h1.641l-1.354 4.292a.359.359 0 0 0 .343.459h2.667a.362.362 0 0 0 .333-.224l.219-.573a.355.355 0 0 0-.334-.474h-.193l1.505-4.901a.347.347 0 0 0-.052-.318l-.5-.672v-.005a.355.355 0 0 0-.281-.141h-1.917a.348.348 0 0 0-.25.109l-.536.589h-.828l-.057-.063 5.927-5.927h.036l-.021-.016zM13.12 28.188l2.104-6.016h-.672l.401-.406h2.208l-2.083 6.078h.833l-.109.344zm4.922-10.027.203.203-.359 1.229-.302.302h-1.292l-.24-.24.417-1.161.38-.333zm-10.589 9.61H5.172l-.354-.198V4.12H3.172l-.135-.13V2.422l.193-.208h9.828l.286.286v1.479l-.193.229h-1.438v11.583L23.458 4.208h-2.781l-.234-.25V2.406l.161-.146h9.984l.177.177v1.427L17.307 17.666h-.557l-.026.005a.41.41 0 0 0-.156.078l-.458.396-.005.005a.407.407 0 0 0-.099.146l-.391 1.109zm19.693-5.266.63-.693h1.776l.417.552-1.688 5.474h.656l-.109.281h-2.375l1.5-4.755h-2.688l-1.438 4.521h.568l-.099.234h-2.141l1.479-4.729h-2.797l-1.417 4.453h.583l-.099.276H17.69l2.021-5.948h-.781l.12-.359h2.198l.693.714h1.208l.656-.734h1.411l.656.714z"/>
</svg>

After

Width:  |  Height:  |  Size: 1.6 KiB

View File

@ -1,6 +1,5 @@
import markdown from '@wcj/markdown-to-html'; import markdown from '@wcj/markdown-to-html';
import rehypeDocument from 'rehype-document'; import rehypeDocument from 'rehype-document';
import rehypeFormat from 'rehype-format';
import remarkGemoji from 'remark-gemoji'; import remarkGemoji from 'remark-gemoji';
import rehypeAutolinkHeadings from 'rehype-autolink-headings'; import rehypeAutolinkHeadings from 'rehype-autolink-headings';
import rehypeSlug from 'rehype-slug'; import rehypeSlug from 'rehype-slug';
@ -26,7 +25,6 @@ export function create(str = '', options = {}) {
rehypePlugins: [ rehypePlugins: [
rehypeSlug, rehypeSlug,
rehypeAutolinkHeadings, rehypeAutolinkHeadings,
rehypeFormat,
[rehypeDocument, { [rehypeDocument, {
title: `${title ? `${title} & ` : ''} ${subTitle} Quick Reference`, title: `${title ? `${title} & ` : ''} ${subTitle} Quick Reference`,
css: [ ...options.css ], css: [ ...options.css ],

View File

@ -27,7 +27,7 @@ body {
--color-prettylights-syntax-entity-tag: #116329; --color-prettylights-syntax-entity-tag: #116329;
--color-prettylights-syntax-keyword: #cf222e; --color-prettylights-syntax-keyword: #cf222e;
--color-prettylights-syntax-string: #0a3069; --color-prettylights-syntax-string: #0a3069;
--color-prettylights-syntax-variable: #953800; --color-prettylights-syntax-variable: #d15104;
--color-prettylights-syntax-brackethighlighter-unmatched: #82071e; --color-prettylights-syntax-brackethighlighter-unmatched: #82071e;
--color-prettylights-syntax-invalid-illegal-text: #f6f8fa; --color-prettylights-syntax-invalid-illegal-text: #f6f8fa;
--color-prettylights-syntax-invalid-illegal-bg: #82071e; --color-prettylights-syntax-invalid-illegal-bg: #82071e;
@ -136,19 +136,33 @@ ol, ul, menu {
padding: 0; padding: 0;
} }
.wrap-body > p > code { yel {
color: var(--color-prettylights-syntax-variable);
}
pur {
color: var(--color-prettylights-syntax-entity);
}
.wrap-body > p > code, .wrap-body > ul li > code, .wrap-body tbody td code {
--text-opacity: 1; --text-opacity: 1;
color: rgb(5 150 105/var(--text-opacity)); color: rgb(5 150 105/var(--text-opacity));
} }
.wrap-body em, .wrap-body sup, .wrap-body sub {
color: var(--color-prettylights-syntax-sublimelinter-gutter-mark);
}
table { table {
width: 100%; width: 100%;
text-indent: 0; text-indent: 0;
border-color: inherit; border-color: inherit;
border-collapse: collapse border-collapse: collapse
} }
table td:first-child {
white-space: nowrap;
}
table td:not(:last-child)>code, table td:not(:last-child)>del>code, ul li > code, kbd { table.shortcuts td:not(:last-child)>code, table.shortcuts td:not(:last-child)>del>code, ul.shortcuts li > code, kbd {
background-color: var(--color-neutral-muted); background-color: var(--color-neutral-muted);
color: var(--color-fg-subtle); color: var(--color-fg-subtle);
box-shadow: 0 0 #0000, 0 0 #0000, 0 0 #0000; box-shadow: 0 0 #0000, 0 0 #0000, 0 0 #0000;
@ -570,7 +584,6 @@ body:not(.home) .h2wrap > h2 a::after {
.h2wrap-body { .h2wrap-body {
font-size: 0.925rem; font-size: 0.925rem;
line-height: 1.325rem;
grid-template-columns: repeat(3,minmax(0,1fr)); grid-template-columns: repeat(3,minmax(0,1fr));
flex-direction: column; flex-direction: column;
} }
@ -690,7 +703,7 @@ body:not(.home) .h2wrap > h2 a::after {
color: var(--color-prettylights-syntax-constant); color: var(--color-prettylights-syntax-constant);
} }
.token.punctuation { .token.punctuation {
color: var(--color-prettylights-syntax-markup-bold); color: var(--color-prettylights-syntax-markup-ignored-bg);
} }
.code-line .token.deleted { .code-line .token.deleted {
background-color: var(--color-prettylights-syntax-markup-deleted-bg); background-color: var(--color-prettylights-syntax-markup-deleted-bg);