在不使用视觉选择的情况下粘贴分隔符 [英] Pasting inside delimiters without using visual selection

查看:24
本文介绍了在不使用视觉选择的情况下粘贴分隔符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 Vim 中,假设我想用另一个字符串的内容替换一个字符串的内容.

In Vim, let's say I want to replace the contents of one String with the content of another.

原始输入

var1 = "January"
var2 = "February"

期望输出

var1 = "January"
var2 = "January"

我通常会做的是:

  • 将光标移动到第 1 行
  • y i " (猛拉内引号)
  • 将光标移动到第 2 行中的目标引用
  • v i " p(视觉选择内引号,粘贴)
  • Move cursor to line 1
  • y i " (yank inner quotes)
  • Move cursor to the destination quote in line 2
  • v i " p (visual select inner quotes, paste)

虽然这很有效,但我通常会尽可能避免使用可视模式,所以我对第 4 步并不完全满意 (v i " p).

While this works well, I generally try to avoid visual mode when possible, so I am not completely satisfied with my step 4 (v i " p).

有没有办法在不使用可视模式的情况下指定目标粘贴区域"?我怀疑它可能是链接到 g 的东西,但我想不出任何东西.

Is there any way to specify a "destination paste area" without using Visual mode? I suspect it might be something chained to g, but I can't think of anything.

推荐答案

我经常需要这个,我写了一个插件来简化并允许最大速度:ReplaceWithRegister.

I need this so often, I wrote a plugin to simplify and allow maximum speed: ReplaceWithRegister.

这个插件提供了一个二合一的 gr 命令,用寄存器的内容替换 {motion}/文本对象、整行或当前选择覆盖的文本;旧文本被删除到黑洞寄存器中,即它消失了.它透明地处理许多极端情况,并允许通过标准的 . 命令快速重复.如果您不喜欢它,它的页面会提供替代链接.

This plugin offers a two-in-one gr command that replaces text covered by a {motion} / text object, entire line(s) or the current selection with the contents of a register; the old text is deleted into the black-hole register, i.e. it's gone. It transparently handles many corner cases and allows for a quick repeat via the standard . command. Should you not like it, its page has links to alternatives.

这篇关于在不使用视觉选择的情况下粘贴分隔符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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