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

在Vim中为yanking选择不相交的代码块

发布时间:2020-12-15 17:00:17 所属栏目:安全 来源:网络整理
导读:我想知道我能否在Vim中做到这一点: 示例代码: require 'abstract_controller/collector'require 'active_support/core_ext/hash/reverse_merge'require 'active_support/core_ext/array/extract_options'require 'IDONTWANTTHISLINETOBEINCLUDEDINMYYANKRE
我想知道我能否在Vim中做到这一点:

示例代码:

require 'abstract_controller/collector'
require 'active_support/core_ext/hash/reverse_merge'
require 'active_support/core_ext/array/extract_options'
require 'IDONTWANTTHISLINETOBEINCLUDEDINMYYANKREGISTER'
require 'IDONTWANTTHISLINETOBEINCLUDEDINMYYANKREGISTER'

    module ActionMailer #:nodoc:
      class Collector
        include AbstractController::Collector
        attr_reader :responses

        def initialize(context,&block)
          @context = context
          @responses = []
          @default_render = block
        end

        def any(*args,&block)
          options = args.extract_options!
          raise "You have to supply at least one format" if args.empty?
          args.each { |type| send(type,options.dup,&block) }
        end
        alias :all :any

        def custom(mime,options={})
          options.reverse_merge!(:content_type => mime.to_s)
          @context.freeze_formats([mime.to_sym])
          options[:body] = block_given? ? yield : @default_render.call
          @responses << options
        end
      end
    end

现在假设我只想抽出一些线并将它们放在另一个文件中.假设我想要猛拉这些线条:

块1:

require 'abstract_controller/collector'
require 'active_support/core_ext/hash/reverse_merge'
require 'active_support/core_ext/array/extract_options'

块2:

module ActionMailer #:nodoc:
      class Collector
        include AbstractController::Collector
        attr_reader :responses

        def initialize(context,&block)
          @context = context
          @responses = []
          @default_render = block
        end

块3:

def custom(mime,options={})
          options.reverse_merge!(:content_type => mime.to_s)
          @context.freeze_formats([mime.to_sym])
          options[:body] = block_given? ? yield : @default_render.call
          @responses << options
        end
      end
    end

这些线不形成连续的线组,它们是分开的.所以为了实现我想要的东西,我必须分3个步骤来抓住这些块,我觉得很烦人.因为我必须猛拉,切换缓冲区,放置,猛拉,放……等等……

那么,有没有办法更有效地完成这项工作(一步到位)?

在追加模式下使用寄存器:

>视觉上选择前三行,“ay
>在视觉上选择接下来的10行,“Ay(注意大写字母)
>视觉上选择第3块,“Ay
>转到其他缓冲区,“ap

你喜欢寄存器吗? This answer is more in-depth.

(编辑:李大同)

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

    推荐文章
      热点阅读