我想知道我能否在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个步骤来抓住这些块,我觉得很烦人。因为我必须猛拉,切换缓冲区,放置,切换缓冲区,猛拉,切换缓冲区,放......等......
那么,有没有办法更有效地完成这项工作(一步到位)?
答案 0 :(得分:13)
在追加模式中使用注册:
"ay
"Ay
(注意大写字母)"Ay
"ap
你喜欢寄存器吗? This answer is more in-depth