VIM操作
将以下文字复制到vim中并起名为exam.txt:
现在,以互联网为代表的信息技术迅速发展, Internet nowadays, which spearheads information technology, is developing at a breathtaking pace. 引领了生产新变革,创造了人类生活新空间,拓展了国家治理新领域。 It revolutionizes new production processes, creates new spaces in people’s lives, and expands new territories in countries’ domains. 中国大力实施网络强国战略、国家信息化战略、国家大数据战略、"互联网+"行动计划。 Strategically, China is striving to have formidable presence, nationwide informalization, national big data, and internet action plan in the cyber space. 中国大力发展电子商务,推动互联网和实体经济深度融合发展,改善资源配置。 Concurrently it is developing e-commerce, promoting virtual and brick-and-mortar business integration, and improving resource allocation. 这些措施为推动创新发展、转变经济增长方式、调整经济结构发挥积极作用。 These measures intend to drive the development of innovation, alter the fashion of economic growth, and modify economic structures for constructive effectiveness. ---------------------------------------------- 中国欢迎公平、开放、竞争的市场, China embraces a market with a level field, freedom of access and competitiveness. 在自身发展的同时,致力于推动全球数字经济发展。 It endeavors to advance growth not only for itself, but for that of the digital economy worldwide. 中国主张自由贸易,反对贸易壁垒和贸易保护主义。 It has always been China’s position to support free trade and oppose trade barriers and protectionism. 我们希望建立开放、安全的数字经济环境,确保互联网为经济发展和创新服务。 Hopefully we can build an environment for a liberalized and safe digital economy in the web that assures its continuing development and innovation. 我们主张互联网接入应公平、普遍。 We maintain the worldwide-web should be unbiased and widely available. 中国愿加强同其他国家和地区在网络安全和信息技术方面的交流与合作。 China is willing to strengthen exchanges and collaboration with other countries/territories in the safety and technology of internet. 我们应共同推进互联网技术的发展和创新, We should all work together in advancing the development and innovation of internet technology. 确保所有人都能平等分享数字红利,实现网络空间的可持续发展。 As well, we should ensure every participant will reap a fair share of the digital bonuses in order that the development in cyber space will continuee 劝君莫惜金缕衣, Be heeded to indulge not in golden wears; 劝君惜取少年时。 Be cautioned to cherish well youthful years. 花开堪折直须折, Pick nice Flowers timely while in bloom. 莫待无花空折枝。 Pick not flowerless branches as in doom.
1. 加上行号显示
-
编辑and创建文件
-
按
a后粘贴
- 按
ESC,输入:set nu
2. 跳到最后一行,在最后一行的下面添加一句话: 诗歌的题目是: 金缕衣
- 按
G或ctrl+g到最后一行
- 按
o跳到下一行
- 按
a后粘贴内容
3. 复制第2题的整行,粘贴到 Be heeded to indulge not in golden wears的上一行
- 命令行模式,在最后一行,按两下
y即yy,复制整行
- 输入
/Be heed搜素目标行,回车定位
- 光标往上一行,按
p粘贴
4. 在第20行向右移动15个字符,写出命令
-
非:命令行输入
20gg,定位到第20行
-
输入
15l,向右移动15个字符
5. 把金缕衣的诗词加上#注释
- 命令行输入
/金缕衣,确认下位置
- 按下
ctrl+v进入列编辑模式,选中28-37行
- 按
I(大写i),输入#,再按两下ESC
- 按下
ctrl+v进入列编辑模式,选中30-36行
- 按
x删除#号这样就把全部金缕衣的诗词加上#注释了
6. 将全文中China 换成 chinese
- 命令行模式下,输入
:0,$s/China/chinese/g(从第0行到最后一行中所有China换成chinese)
7. 在vim中不离开vim执行 ls/etc/hosts
- 命令行模式下,输入
:! ls /etc/hosts
8. 把 cat /etc/hosts的内容添加到文章开头
- 把光标移到开头,按
gg
- 输入
:r /etc/hosts
9. 删除第六和第七行
- 按
6gg定位到第六行
- 按两下
d,即dd删除第六行,第七行同理
10. 去掉行首和行尾
- 以第一句为例,
gg到第一行,按7l到为的位置
- 按下
d0,为前面的字全部删除了
- 按下
8l到迅的位置
- 按下
d$,包括迅以及后面的字全部删除了
11. 不区分大小写将flower改为fresh
- 设置不区分大小写,输入
:set ic,输入/flower查找有两个符合
- 输入
:34,36s/flower/fresh,替换34-36行中两处
12. 将ifconfig的所有内容,添加到第16行的行尾
- 按下
16gg,再按$到16行行尾
- 命令输入
:! ifconfig,查看输出内容
- 复制后按
a,再粘贴至行尾