微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

vim中的这一系列击键如何删除除编号线之外的所有内容?

通过这个 just the middle卡塔,

Leave only the
numbered lines.
LINE 1
LINE 2
LINE 3
That's all.
Thank you
very much.

以下按键序列是有意义的,并在缓冲区中执行某些操作:

djGd2kZZ

它基本上将命令链接在一起.但是下面做了什么,为什么我不能在缓冲区中看到它?我试着省略“q!” (退出?)命令但是它没有用.

)3:wq!<CR>

解决方法

)是一个跳过一句话的 motion.一句话是:

*sentence*

    A sentence is defined as ending at a '.','!' or '?' followed by either the
    end of a line,or by a space or tab.

在这文件中:

Leave only the
numbered lines.
LINE1

前两行是以点和换行结尾的句子,因此将光标移动到LINE 1的开头.

:WQ< CR>!是保存和退出的常用顺序,在没有提示的情况下进行覆盖.

诀窍是:w accepts a range command

:[range]w[rite][!] [++opt]

    Write the specified lines to the current file.  This
    is unusual,because the file will not contain all
    lines in the buffer.

在之前输入一个数字:是N:Count and Range

Count and Range                     *N:*

    When giving a count before entering ":",this is translated into:
        :.,.+(count - 1)

    In words: The 'count' lines at and after the cursor.  Example: To delete
    three lines:
        3:d<CR>    is translated into: .,.+2d<CR>

3:w变为:.,. 2w意思是写当前行和以下两行.

)3:WQ< CR>!不删除除编号行以外的所有内容,它会将编号行保存在原始文件上.当Vim强制退出时,文本的其余部分将丢失.这就是为什么你看不到缓冲区的变化 – 它不会改变.

(过了一段时间,我自己也得到了djGd2kZZ这个,并且不知道你能做[范围]:直到我看到更短的答案).

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐