如何在 Eclipse 的 Vim 中复制整行?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/73319/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-10 18:22:47  来源:igfitidea点击:

How to duplicate a whole line in Vim at Eclipse?

eclipsevimeditorkeyboard-shortcutsvi

提问by sumek

How do I duplicate a whole line in Vimin a similar way to Ctrl+Din IntelliJ IDEA/ Resharper or Ctrl+Alt+/in Eclipse?

如何复制在一整行的Vim以类似的方式来Ctrl+D中的IntelliJ IDEA / ReSharper的或Ctrl+ Alt+ /Eclipse中

回答by Mark Biek

yyor Yto copy the line (mnemonic: yank)
or
ddto deletethe line (Vim copies what you deleted into a clipboard-like "register", like a cutoperation)

yyY复制行(助记:ŸANK

dddelete行(VIM拷贝你删除到剪贴板中,如“注册”,像操作)

then

然后

pto pastethe copied or deleted text afterthe current line
or
Pto pastethe copied or deleted text beforethe current line

ppASTE的复制或删除文本之后当前行

PpASTE的复制或删除文本之前当前行

回答by Benoit

Normal mode: see other answers.

正常模式:请参阅其他答案。

The Exway:

防爆方式:

  • :t.will duplicate the line,
  • :t 7will copy it after line 7,
  • :,+t0will copy current and next line at the beginning of the file (,+is a synonym for the range .,.+1),
  • :1,t$will copy lines from beginning till cursor position to the end (1,is a synonym for the range 1,.).
  • :t.将复制该行,
  • :t 7将在第 7 行之后复制它,
  • :,+t0将复制文件开头的当前行和下一行(,+是范围的同义词.,.+1),
  • :1,t$将复制从开始到光标位置到结束的行(1,是范围的同义词1,.)。

If you need to move instead of copying, use :minstead of :t.

如果您需要移动而不是复制,请使用:m代替:t

This can be really powerful if you combine it with :gor :v:

如果将它与:gor结合使用,这会非常强大:v

  • :v/foo/m$will move all lines not matching the pattern “foo” to the end of the file.
  • :+,$g/^\s*class\s\+\i\+/t.will copy all subsequent lines of the form class xxxright after the cursor.
  • :v/foo/m$将所有与模式“foo”不匹配的行移动到文件末尾。
  • :+,$g/^\s*class\s\+\i\+/t.class xxx在光标后立即复制表单的所有后续行。

Reference: :help range, :help :t, :help :g, :help :mand :help :v

参考::help range:help :t:help :g:help :m:help :v

回答by Linulin

YPor Ypor yyp.

YPYpyyp

回答by Adam

copy and paste in vim

在vim中复制和粘贴

Doesn't get any simpler than this! From normal mode:

没有比这更简单的了!从正常模式:

yy

then move to the line you want to paste at and

然后移动到要粘贴的行

p

回答by pjz

yy

yy

will yank the current line without deleting it

将猛拉当前行而不删除它

dd

dd

will delete the current line

将删除当前行

p

p

will puta line grabbed by either of the previous methods

put前一种方法是否会抓取一条线

回答by Eric Z Beard

Do this:

做这个:

First, yyto copy the current line, and then pto paste.

首先,yy复制当前行,然后p粘贴。

回答by Kwondri

If you want another way:

如果你想要另一种方式:

"ayy: This will store the line in buffer a.

"ayy:这会将行存储在缓冲区中a

"ap: This will put the contents of buffer aat the cursor.

"ap: 这会将缓冲区的内容放在a光标处。

There are many variations on this.

这方面有很多变化。

"a5yy: This will store the 5 lines in buffer a.

"a5yy:这将在缓冲区中存储 5 行a

See "Vim help filesfor more fun.

请参阅“ Vim 帮助文件以获得更多乐趣。

回答by theschmitzer

yyp- remember it with "yippee!"

yyp- 记住“yippee!”

Multiple lines with a number in between:

多行中间有一个数字:

y7yp

y7yp

回答by yemu

yyp- paste after

yyp- 粘贴后

yyP- paste before

yyP- 粘贴之前

回答by yemu

I like: Shift+v(to select the whole line immediately and let you select other lines if you want), y, p

我喜欢: Shift+ v(立即选择整行并让您根据需要选择其他行),y,p