Vim/vi 生存指南 [英] Vim / vi Survival Guide

查看:28
本文介绍了Vim/vi 生存指南的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

基本的vim命令是什么?新用户需要知道什么才能避免陷入困境?请为每条评论一条命令.

What are the essential vim commands? What does a new-user need to know to keep themselves from getting into trouble? One command per comment, please.

推荐答案

我认为不可替代的(因为它也适用于 vi,不像 vim 的可视模式)是标记.您可以使用 m(小写)和您选择的字母(例如 x)标记各个点.然后你去别处,可以用``x(反引号字母)返回到确切的位置,或者用'x`(撇号字母)回到该行.

What I find irreplaceable (because it works in vi also, unlike vim's visual mode) are marks. You can mark various spots with m (lower case) and then a letter of your choice (eg x). Then you go elsewhere, and can go back with ``x(backquote letter) to the exact spot, or with'x` (apostrophe letter) to go to the line.

这些动作可以用作命令的参数(猛拉、删除等).比如你要删除10行;不是计数然后移动到最上面一行并输入 10dd,而是转到块的开头或结尾,按 mm(标记 m),然后转到到块的另一端,然后按 d'm(删除撇号 m).如果在此示例中使用反引号而不是撇号,则删除将按字符进行,而不是按行进行.尝试用mark m"在该行的中间标记,移动到另一行的中间,然后输入d backquote m",你就会明白我的意思.

These movements can be used as arguments to commands (yank, delete, etc). For example, you want to delete 10 lines; instead of counting and then moving to the topmost line and entering 10dd, you go to either the start or the end of the block, press mm (mark m), then go to the other end of the block, and press d'm (delete apostrophe m). If you use backquote instead of apostrophe in this example, then the deletion will work character-wise, not line-wise. Try marking in the middle of the line with "mark m", moving to the middle of another line, then entering "d backquote m" and you will see what I mean.

这篇关于Vim/vi 生存指南的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆