Visual Studio:快捷键:重复行 [英] Visual Studio : short cut Key : Duplicate Line

查看:117
本文介绍了Visual Studio:快捷键:重复行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Visual Studio 2008中是否存在 重复行 命令的快捷方式?

Is there a shortcut for Duplicate Line command in Visual Studio 2008?

一些类似的例子:

  • in Notepad++, I can duplicate the current line with: Ctrl+D
  • in EditPlus: Ctrl+J
  • in NetBeans: Ctrl+Shift+/
  • in Eclipse, Ctrl+Alt+/
  • in Vi/Vim, yyp
  • etc.

推荐答案

在Visual Studio 2019中

Ctrl + D

Ctrl + D

(edit)此功能现在已在VS2017中内置: Ctrl + E V 如果未选择任何内容,则会复制一行,或重复选择.您可以将其分配给其他组合键,也可以在菜单中找到它:

(edit) This feature is now built-in in VS2017: Ctrl + E, V duplicates a line if nothing is selected, or duplicates selection. You can assign it to a different key combination, or find it in the menu:

请参见

See this reference for more information.

如@cand所述,您只需执行 Ctrl + C 即可; Ctrl + V .

As @cand mentioned, you can just do Ctrl + C ; Ctrl + V.

Ctrl + C 将复制该行.

如果您想实施一个更完整的解决方案,或者创建一个更简单的键盘快捷键,或者不想影响剪贴板,请参见本指南:

If you'd like to implement a more complete solution, perhaps to create a simpler keyboard shortcut or you don't want to effect the clipboard, see this guide:

Visual Studio的重复行命令

Visual Basic:

Visual Basic:

Imports System
Imports EnvDTE
Imports EnvDTE80
Imports System.Diagnostics

Public Module DuplicateLastLineModule
    Sub DuplicateLine()
        Dim line As String
        DTE.ActiveDocument.Selection.StartOfLine(0)
        DTE.ActiveDocument.Selection.EndOfLine(True)
        line = DTE.ActiveDocument.Selection.Text
        DTE.ActiveDocument.Selection.EndOfLine()
        DTE.ActiveDocument.Selection.NewLine()
        DTE.ActiveDocument.Selection.StartOfLine(0)
        DTE.ActiveDocument.Selection.Text = line
    End Sub
End Module

要创建宏,只需转到宏资源管理器 (工具-> Macros-> Macro Explorer"或 Alt + F8 ),然后将代码复制粘贴到 一个新模块.现在,只需为其分配键盘快捷键即可:

To create the macro, just go to the macro explorer ("Tools->Macros->Macro Explorer" or Alt+F8) and copy paste the code in a new module. Now just assign a keyboard shortcut to it:

  1. 转到工具"->选项" ...
  2. 在环境"下,单击键盘"
  3. 在显示包含的命令"文本框中,输入重复"(根据您给模块指定的名称).
  4. 您现在应该在下面的列表中看到宏
  5. 从使用新的快捷方式"列表中选择文本编辑器"
  6. 在按快捷键"文本框中设置焦点,然后按您希望用于键盘的组合键( Ctrl + Shift + D 中 我的情况)
  7. 点击分配"按钮
  8. 您现在应该在所选命令的快捷方式"文本框中看到该快捷方式
  9. 点击确定"按钮
  1. go to Tools->Options...
  2. under Environment, click Keyboard
  3. in the "Show Commands Containing" textbox, enter "duplicate" (this according to the name you gave the module.)
  4. you should now see the macro in the list below
  5. choose "Text Editor" from the "Use new shortcut in" list
  6. set focus in the "Press shortcut keys" textbox and hit the combination on the keyboard you whish to use for it (Ctrl+Shift+D in my case)
  7. hit the "Assign" button
  8. you should now see the shortcut in the "Shortcuts for selected command" textbox
  9. hit the OK button

就是这样.享受吧!

这篇关于Visual Studio:快捷键:重复行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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