全部博文(236)
分类: LINUX
2022-01-10 10:35:29
"h",
"b",
"f",
"d",
"e",
"a",
"c",
]
```
- `:g/\[/+1,/\]/-1sort`
- 在这个中括号的范围内
- 排序
## 总结
- 这次研究的是global
- `:[range]global/{pattern}/{command}`
- range是执行的范围
- pattern是搜索的模式
- command执行的命令
- 命令有很多
- d 删除
- m 移动
- t 拷贝
- p 打印
- s 替换
- sort 排序
- update 更新
- global是很好用的内部命令
- vim还可以执行外部命令呢!
- 怎么玩呢?????
- 下次再说!
命令可以带上
:[range]global/{pattern}/{command}
range是执行的范围
匹配这个模式
或者不匹配这个模式
const oeasy = 1; console.log("oeasy: ", oeasy); const o2z = 2; console.log("o2z: ", o2z); const o3z = 3; console.log("o3z: ", o3z);
:g/console/d
:g/const/d
:g/console/d _
:g/console/d|update
:g@console@d
什么不能当分割符
什么可以当分隔符
:g+//+s/oeasy/o1z/g
g
//
s/oeasy/o1z/g
:g/console/d
:v/console/d
:g!/console/d
:g/^$/d
:g/^\s*$/d
:1,5g/console/d
:.,5g/console/d
:3,.g/console/d
:3g/console/d
特定行
const oneMillion = 1000000; const oneThousand = 1000; const one = 1;
可以把数值分别调整一下
:g/.*/normal A;
:g/./normal A;
const oeasy = 1 console.log("oeasy: ", oeasy); const o2z = 2 console.log("o2z: ", o2z); const o3z = 3 console.log("o3z: ", o3z);
qaA;
:reg a
:g/const/normal @a
const
normal @a
:2,$g/const/normal @a
2,$
const
:normal @a
const oeasy = 1 console.log("oeasy: ", oeasy); const o2z = 2 console.log("o2z: ", o2z); const o3z = 3 console.log("o3z: ", o3z);
:g/console/g/two/d
:g/console/v/two/d
:g/const/p
:g/^/m 0
const oeasy = 1 console.log("oeasy: ", oeasy); // TODO oeasy const o2z = 2 console.log("o2z: ", o2z); // TODO o2z const o3z = 3 console.log("o3z: ", o3z); // TODO o3z
:g/TODO/t $
:g/TODO/m 0
const arrayA = [ "h", "b", "f", "d", "e", "a", "c", ]
:[range]global/{pattern}/{command}
命令有很多