简体   繁体   English

Eclipse 复制/粘贴整行键盘快捷键

[英]Eclipse copy/paste entire line keyboard shortcut

Anyone know the keyboard shortcut to copy/paste a line into a new line in Eclipse , without having to highlight the entire line?任何人都知道在Eclipse一行复制/粘贴到新行中的键盘快捷键,而不必突出显示整行?

ctrl - alt - down turns my whole screen upside down (I'm on windows). ctrl - alt - down将我的整个屏幕倒置(我在 Windows 上)。 Interestingly, that's what's specified in the windows->preferences.有趣的是,这就是 windows->preferences 中指定的内容。

Ctrl - Alt - Down : copies current line or selected lines to below Ctrl - Alt - Down :将当前行或选定行复制到下方

Ctrl - Alt - Up :: copies current line or selected lines to above Ctrl - Alt - Up :: 将当前行或选定行复制到上方

Ctrl - Shift - L : brings up a List of shortcut keys Ctrl - Shift - L :调出快捷键列表

See Windows/Preference->General->Keys.请参阅 Windows/首选项-> 常规-> 键。

(Tested on Windows) [Per below comments, works as well in Ubuntu, IBM RTC 4 / RSA 9] (在 Windows 上测试)[根据以下评论,在 Ubuntu、IBM RTC 4 / RSA 9 中也能正常工作]

  1. In Eclipse, press Ctrl + Shift + L two times in succession (or Ctrl + 3 > type: Keys > Enter ).在 Eclipse 中,连续按Ctrl + Shift + L两次(或Ctrl + 3 > 键入: Keys > Enter )。
  2. In 'type filter text' (search) text box, type Copy Lines在“键入过滤器文本”(搜索)文本框中,键入Copy Lines
  3. Select the filtered row, right click the 'Binding' field, and do Select All选择过滤后的行,右键单击“绑定”字段,然后执行Select All
  4. Press Ctrl + Shift + VCtrl + Shift + V
  5. Give OKOK

From now on, for any line you want to duplicate, just press Ctrl + Shift + V .从现在开始,对于要复制的任何行,只需按Ctrl + Shift + V

You have to turn off the graphics hot keys that flip the screen.您必须关闭翻转屏幕的图形热键。 If you're on Windows, you need to right click on the Windows desktop and select "Graphics Properties..." (or something similar depending on your version of Windows).如果您使用的是 Windows,则需要右键单击 Windows 桌面并选择“图形属性...”(或类似的选项,具体取决于您的 Windows 版本)。 This will bring up a screen where you can manage graphics and display options, look for a place where you can disable hot keys, sometimes it's hidden under something like "Options and Support".这将打开一个屏幕,您可以在其中管理图形和显示选项,寻找可以禁用热键的地方,有时它会隐藏在“选项和支持”之类的东西下。 Turn off the CTRL + ALT + and CTRL + ALT + hotkeys (alternatively you can just disable all graphics hot keys if you're not using them).关闭CTRL + ALT + CTRL + ALT + 热键(或者,如果您不使用它们,则可以禁用所有图形热键)。

If you want to copy a line to the clipboard you can also use the trick:如果要将一行复制到剪贴板,也可以使用以下技巧:

Ctrl - Alt - Down followed by Ctrl - X Ctrl - Alt -向下,然后是Ctrl - X

The drawback is that the file where you copy the line from becomes dirty.缺点是您从中复制该行的文件变脏了。

  1. Ctrl - D would delete a line Ctrl - D删除一行
  2. Ctrl - Z would undo deletion, with highlithing entire line Ctrl - Z将撤消删除,高亮​​整行
  3. Ctrl - X / C cut or copy entire line Ctrl - X / C剪切或复制整行

The advantage over Ctrl - Alt - Down followed by Ctrl - X suggested by other users is that it doesn't make eclipse think that the file was changed in any way.与其他用户建议的Ctrl - Alt - Down后跟Ctrl - X相比的优势在于,它不会让 eclipse 认为文件以任何方式被更改。 It's also faster and causes no problems even if the user has rotating screen issue with Ctrl - Alt - Down / Up keyboard shorcut.即使用户使用Ctrl - Alt - Down / Up键盘快捷出现旋转屏幕问题,它也更快并且不会导致任何问题。 So there's no need to remap shorcuts for this.所以没有必要为此重新映射快捷方式。

Another way to go would be hitting Alt - Shift - Up until the entire line gets selected.另一种方法是按 Alt - Shift - Up直到选中整行。 If you've gone too far, of course you can select less with Alt - Shift - Down .如果你走得太远,当然你可以用Alt - Shift - Down选择更少。

If Your Window pc, you may try this, it's also for STS:如果你的 Window 电脑,你可以试试这个,它也适用于 STS:

Ctrl + win + Alt + Down :: Copy current line or selected line to below Ctrl + win + Alt + Down :: 将当前行或选定行复制到下方

Ctrl + win + Alt + Up :: Copy current line or selected line to above Ctrl + win + Alt + Up :: 将当前行或选定行复制到上方

I've written the linecopypaste plugin for Eclipse that mimics Visual Studio's copy/cut/paste behaviour.我已经为 Eclipse 编写了linecopypaste插件,它模仿了 Visual Studio 的复制/剪切/粘贴行为。 I've also found copycutcurrentline which appears to do the same.我还发现copycutcurrentline似乎也做同样的事情。

On my Mac the default setting is is ALT + CMD + Down在我的 Mac 上,默认设置是ALT + CMD + Down

You can change/view all key bindings by going Eclipse -> Preferences (shortcut CMD + , ) and then General -> Keys您可以通过转到 Eclipse -> Preferences(快捷键CMD + , )然后 General -> Keys 来更改/查看所有键绑定

Ctrl + Alt + Down Copies current line to below like notepad++ ( Ctrl + D ) Ctrl + Alt + Down像记事本++一样将当前行复制到下方( Ctrl + D

If your whole screen is 180° rotted then you should disable your hotkey settings.如果您的整个屏幕旋转 180°,那么您应该禁用热键设置。

Right Click -> Graphics Options -> Hot Keys -> Disable右键单击 -> 图形选项 -> 热键 -> 禁用

在此处输入图片说明

That it now you done try shortcut Ctrl + Alt + Down现在你完成了尝试快捷键Ctrl + Alt + Down

Try this in MAC.在 MAC 中试试这个。

ALT + COMMAND + DOWN ALT +命令+向下

it works.有用。

If anyone using Mac computer the CTRL + ALT + DOWN keys doesn't work.如果有人使用 Mac 计算机,则CTRL + ALT + DOWN键不起作用。

Try it with,试试看,

ALT + COMMAND + DOWN ALT +命令+向下

It works.有用。

I have to change the assigned key, eg我必须更改分配的键,例如

Windows/Preference --> General --> Keys Windows/首选项 --> 常规 --> 键

Select "Duplicate Lines" under command Click on "Binding" Ctrl + Shift + D在命令下选择“Duplicate Lines” 单击“Binding” Ctrl + Shift + D

On Mac, I've tried the linecopypaste and it works great cmd + c -> Copy current (unselected) line, just like "yy" command in Vi/Vim cmd + v -> Paste it, like "p" command in Vi/Vim在 Mac 上,我尝试了linecopypaste并且效果很好cmd + c -> 复制当前(未选择的)行,就像 Vi/Vim 中的“yy”命令cmd + v -> 粘贴它,就像 Vi 中的“p”命令/vim

Thank's Larsch for your work!感谢 Larsch 的工作!

PD: Using Eclipse Luna 4.4.2 in Yosemite PD:在优胜美地使用 Eclipse Luna 4.4.2

Disabling the hot keys for the Intel Driver worked for me for Windows 7. However, for Windows 8, when I tried that, it prevented eclipse from getting the Ctrl - Alt - Down keystoke.禁用英特尔驱动程序的热键适用于 Windows 7。但是,对于 Windows 8,当我尝试这样做时,它阻止了 Eclipse 获得Ctrl - Alt - Down按键。 I had to change the Intel driver key binding to Ctrl - Alt - F10 (or something else it will accept).我不得不将 Intel 驱动程序键绑定更改为Ctrl - Alt - F10 (或它会接受的其他东西)。 Eclipse then gets the Ctrl - Alt - Down and copies the line. Eclipse 然后获取Ctrl - Alt - Down并复制该行。

Just another approach:只是另一种方法:

1) Alt+Up and Alt+Down (or Alt+Down and Alt+Up, order does not matter)
2) Ctrl+C

But of course vim's "yy" is the fastest :)但是当然 vim 的 "yy" 是最快的 :)

对于 mac, shift + alt + down_arrow在 netbeans 的编辑器中工作。

We can assign any command to any action(given) in Eclipse From Menu Bar go to Window > Preferences then search for the keys then search copy line then click on copy line and then click on command in Binding and peform a command which you wish to use for duplicating line i use ctrl+shift+d you can choose whatever you want我们可以将任何命令分配给 Eclipse 中的任何操作(给定)从菜单栏中转到窗口 > 首选项,然后搜索键,然后搜索复制行,然后单击复制行,然后单击绑定中的命令并执行您希望执行的命令用于复制行我使用 ctrl+shift+d 你可以选择任何你想要的在此处输入图片说明

I am using Windows 7. To disable that all I did is to Right click on the Windows desktop and select "Graphics Properties" ->Options.我使用的是 Windows 7。要禁用它,我所做的就是右键单击 Windows 桌面并选择“图形属性”->“选项”。 Then selected "Off" at the left side on the resulting screen.然后在结果屏幕的左侧选择“关闭”。 This disabled all hotkey combination.这禁用了所有热键组合。 I think there is no way to disable only some them, its all or none.我认为没有办法只禁用一些,要么全部禁用,要么不禁用。 Anyway I didn't need them.反正我不需要它们。 So now crtl+Alt+Up and Crtl+Alt+down works for me in Eclipse and my screen stays same :) I think similar option also exist in other versions of Windows.所以现在 crtl+Alt+Up 和 Crtl+Alt+down 在 Eclipse 中对我有用,我的屏幕保持不变:) 我认为类似的选项也存在于其他版本的 Windows 中。 Have fun :)玩得开心 :)

It's working with me on , Eclipse + Spring tool suite .它在 Eclipse + Spring 工具套件上与我合作。

ALT + COMMAND + DOWN ALT +命令+向下

To copy text from the begining of line to the cursor position: ctrl + insert将文本从行首复制到光标位置: ctrl + insert

It does the job and save a lot of time for me.它可以完成工作并为我节省大量时间。

ctrl + alt + down / up / left / right takes precedence over eclipse settings as hot keys. ctrl + alt + down / up / left / right优先于 eclipse 设置作为热键。 As an alternative, I try different approach.作为替代方案,我尝试不同的方法。

Step 1: Triple click the line you want to copy & press `Ctrl`-`C`(This will
select & copy that entire line along with the `new line`).
Step 2: Put your cursor at the starting of the line where you want to to paste
your copied line & press `Ctrl`-`V`.(This will paste that entire line & will
push previous existing line to the new line, which we wanted in the first place).

The Ctrl + Alt + Down / Ctrl + Alt + Up flips my screen so I overrode that in the Eclipse shortcuts via Window => Preferences => General => Keys. Ctrl + Alt + Down / Ctrl + Alt + Up翻转了我的屏幕,所以我通过 Window => Preferences => General => Keys 在 Eclipse 快捷方式中覆盖了它。 Search for "dupl" to find the Duplicate Lines command.搜索“dupl”以查找重复行命令。 I overrode the default and chose Ctrl + Shift + D .我覆盖了默认设置并选择了Ctrl + Shift + D For me, that's easy to remember just like Ctrl + D to delete lines对我来说,这很容易记住,就像Ctrl + D删除行一样

对于个人使用,我在 Eclipse 中添加了一个像Vrapper这样的 vim 插件,然后使用yy复制整行。

Ctrl + Shift + Alt + Down的组合在 Linux 上对我有用。

Another shortcut way to do this is press Ctrl+Shift+L and select which command you want to perform and hit enter另一种快捷方式是按 Ctrl+Shift+L 并选择要执行的命令并按 Enter 在此处输入图片说明

its best practice for beginner.初学者的最佳实践。

See how to make the eclipse default shortcut work ctrl alt 查看如何使 eclipse 默认快捷方式起作用ctrl alt

  1. Select line: Put cursor on the line to copy, select line with Shift Home if cursor in the end of line or Shift End if cursor is in starting of line Select line: Put cursor on the line to copy, select line with Shift Home if cursor in the end of line or Shift End if cursor is in starting of line
  2. Duplicate line below (default expected behavior) or above ctrl alt or ctrl alt but the key here is you need to select the line/block重复行下方(默认预期行为)或上方ctrl alt ctrl alt 但这里的关键是您需要 select 行/块

Some answers focus on disabling the screen Rotation in Windows or any other OS, that applies to prevent accidental keypress.一些答案侧重于在 Windows 或任何其他操作系统中禁用屏幕旋转,以防止意外按键。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM