加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

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

发布时间:2020-12-15 21:23:30 所属栏目:安全 来源:网络整理
导读:通过这个 just the middle卡塔, Leave only thenumbered lines.LINE 1LINE 2LINE 3That's all.Thank youvery much. 以下按键序列是有意义的,并在缓冲区中执行某些操作: djGd2kZZ 它基本上将命令链接在一起.但是下面做了什么,为什么我不能在缓冲区中看到它?
通过这个 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这个,并且不知道你能做[范围]:直到我看到更短的答案).

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读